url-sanitizer 4.2.1 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -39,12 +39,12 @@
39
39
  "esbuild": "^0.28.1",
40
40
  "eslint": "^9.39.5",
41
41
  "eslint-config-prettier": "^10.1.8",
42
- "eslint-plugin-jsdoc": "^63.2.2",
42
+ "eslint-plugin-jsdoc": "^63.3.0",
43
43
  "eslint-plugin-prettier": "^5.5.6",
44
44
  "eslint-plugin-regexp": "^3.1.1",
45
45
  "eslint-plugin-unicorn": "^64.0.0",
46
46
  "fast-check": "^4.9.0",
47
- "globals": "^17.7.0",
47
+ "globals": "^17.8.0",
48
48
  "http-server": "^14.1.1",
49
49
  "mitata": "^1.0.34",
50
50
  "mocha": "^11.7.6",
@@ -93,5 +93,5 @@
93
93
  "engines": {
94
94
  "node": ">=22.13"
95
95
  },
96
- "version": "4.2.1"
96
+ "version": "4.2.2"
97
97
  }
@@ -654,7 +654,10 @@ class URLSanitizer extends URISchemes {
654
654
  * @returns {boolean} True if the scheme is registered.
655
655
  */
656
656
  has(scheme) {
657
- return this.#allowedSchemes.has(scheme);
657
+ if (!isString(scheme)) {
658
+ return false;
659
+ }
660
+ return this.#allowedSchemes.has(scheme.trim().toLowerCase());
658
661
  }
659
662
 
660
663
  /**
@@ -663,17 +666,18 @@ class URLSanitizer extends URISchemes {
663
666
  * @returns {string[]} The updated array of registered schemes.
664
667
  */
665
668
  add(scheme) {
669
+ let loweredScheme;
666
670
  if (isString(scheme)) {
667
- scheme = scheme.trim();
671
+ loweredScheme = scheme.trim().toLowerCase();
668
672
  } else {
669
673
  throw new TypeError(`Expected String but got ${getType(scheme)}.`);
670
674
  }
671
- const schemeParts = scheme.split('+');
675
+ const schemeParts = loweredScheme.split('+');
672
676
  const isScript = schemeParts.some(s => REG_SCRIPT.test(s));
673
- if (isScript || !REG_SCHEME.test(scheme)) {
677
+ if (isScript || !REG_SCHEME.test(loweredScheme)) {
674
678
  throw new Error(`Invalid scheme: ${scheme}`);
675
679
  }
676
- this.#allowedSchemes.add(scheme);
680
+ this.#allowedSchemes.add(loweredScheme);
677
681
  return [...this.#allowedSchemes];
678
682
  }
679
683
 
@@ -683,7 +687,10 @@ class URLSanitizer extends URISchemes {
683
687
  * @returns {boolean} True if the scheme was successfully removed.
684
688
  */
685
689
  remove(scheme) {
686
- return this.#allowedSchemes.delete(scheme);
690
+ if (!isString(scheme)) {
691
+ return false;
692
+ }
693
+ return this.#allowedSchemes.delete(scheme.trim().toLowerCase());
687
694
  }
688
695
 
689
696
  /**
@@ -76,7 +76,10 @@ export class URISchemes {
76
76
  * @returns {boolean} True if the scheme is registered.
77
77
  */
78
78
  has(scheme) {
79
- return this.#schemes.has(scheme);
79
+ if (!isString(scheme)) {
80
+ return false;
81
+ }
82
+ return this.#schemes.has(scheme.trim().toLowerCase());
80
83
  }
81
84
 
82
85
  /**