Remove complex reference check, and add a simpler option.

This commit is contained in:
Llewellyn van der Merwe 2023-11-30 19:24:04 +02:00
parent 57482a2b48
commit 0fdb273255
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
4 changed files with 14 additions and 10 deletions

10
dist/js/getBible.js vendored
View File

@ -1,5 +1,5 @@
/**
* getBible Loader v3.0.1
* getBible Loader v3.0.2
* https://getbible.net
* (c) 2014 - 2023 Llewellyn van der Merwe
* MIT License
@ -1246,7 +1246,6 @@
#action;
#element;
#format;
#pattern = /^(?=.*\p{Letter})(?=.*\d)(?=.*:).{1,30}$/u;
/**
* Constructs a Loader instance.
@ -1281,7 +1280,7 @@
}
/**
* Validates a list of references against the specified pattern.
* Validates a list of references to ensure each is no longer than 30 characters and contains at least one number.
* Invalid references are logged and excluded from the return value.
* @param {string[]} references - The array of references to validate.
* @returns {string[]} A filtered array of valid references.
@ -1289,7 +1288,10 @@
*/
#validateReferences(references) {
return references.filter(reference => {
if (!this.#pattern.test(reference)) {
// Check if the reference is not longer than 30 characters and contains at least one number
const isValid = reference.length <= 30 && /\d/.test(reference);
// Log invalid references
if (!isValid) {
console.error(`Invalid getBible reference: ${reference}`);
return false;
}

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
"name": "getbible.loader",
"title": "getBible",
"description": "GetBible is an intuitive and lightweight JavaScript solution for embedding Bible scripture into your website.",
"version": "3.0.1",
"version": "3.0.2",
"main": "dist/js/getBible.min.js",
"scripts": {
"build": "rollup -c"

View File

@ -13,7 +13,6 @@ export class Loader {
#action;
#element;
#format;
#pattern = /^(?=.*\p{Letter})(?=.*\d)(?=.*:).{1,30}$/u;
/**
* Constructs a Loader instance.
@ -48,7 +47,7 @@ export class Loader {
}
/**
* Validates a list of references against the specified pattern.
* Validates a list of references to ensure each is no longer than 30 characters and contains at least one number.
* Invalid references are logged and excluded from the return value.
* @param {string[]} references - The array of references to validate.
* @returns {string[]} A filtered array of valid references.
@ -56,7 +55,10 @@ export class Loader {
*/
#validateReferences(references) {
return references.filter(reference => {
if (!this.#pattern.test(reference)) {
// Check if the reference is not longer than 30 characters and contains at least one number
const isValid = reference.length <= 30 && /\d/.test(reference);
// Log invalid references
if (!isValid) {
console.error(`Invalid getBible reference: ${reference}`);
return false;
}