trousse 3.20.0 → 3.20.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/dist/internal/blank.js +9 -1
- package/dist/internal.js +2 -2
- package/dist/matching.js +3 -3
- package/dist/strings.js +4 -9
- package/dist/urls.js +4 -5
- package/package.json +1 -1
package/dist/internal/blank.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
// src/internal/blank.ts
|
|
2
2
|
const blankCharacterClass = "[\\p{White_Space}\\uFEFF]";
|
|
3
|
-
|
|
3
|
+
const blankCharRegex = new RegExp(blankCharacterClass, "u");
|
|
4
|
+
const stripBlankEdges = (value) => {
|
|
5
|
+
let start = 0;
|
|
6
|
+
let end = value.length;
|
|
7
|
+
while (start < end && blankCharRegex.test(value.charAt(start))) start++;
|
|
8
|
+
while (end > start && blankCharRegex.test(value.charAt(end - 1))) end--;
|
|
9
|
+
return value.slice(start, end);
|
|
10
|
+
};
|
|
11
|
+
export { blankCharacterClass, stripBlankEdges };
|
package/dist/internal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stripBlankEdges } from "./internal/blank.js";
|
|
2
2
|
import { isNonEmptyString, isNullish, isString } from "./is.js";
|
|
3
3
|
// src/internal.ts
|
|
4
4
|
const toPatternList = (patterns) => {
|
|
@@ -13,4 +13,4 @@ const createTrimPredicate = (options, fallback) => {
|
|
|
13
13
|
return keep(value);
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
export {
|
|
16
|
+
export { createTrimPredicate, stripBlankEdges, toPatternList };
|
package/dist/matching.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { stripBlankEdges } from "./internal/blank.js";
|
|
1
2
|
import { toPatternList } from "./internal.js";
|
|
2
3
|
import { isNullish, isString } from "./is.js";
|
|
3
|
-
import { trimString } from "./strings.js";
|
|
4
4
|
// src/matching.ts
|
|
5
5
|
const whitespaceRegex = /\s+/;
|
|
6
6
|
const regexSyntaxCharsRegex = /[.*+?^${}()|[\]\\/]/;
|
|
7
7
|
const regexEscapableCharsRegex = /[.*+?^${}()|[\]\\/&!#%,:;<=>@`~-]/g;
|
|
8
8
|
const foldText = (value) => {
|
|
9
|
-
return (
|
|
9
|
+
return stripBlankEdges(value).toLowerCase();
|
|
10
10
|
};
|
|
11
11
|
const testRegex = (regex, value) => {
|
|
12
12
|
regex.lastIndex = 0;
|
|
@@ -15,7 +15,7 @@ const testRegex = (regex, value) => {
|
|
|
15
15
|
const testRegexPattern = (regex, parsedValue, value, parser) => {
|
|
16
16
|
if (testRegex(regex, parsedValue)) return true;
|
|
17
17
|
if (parser !== foldText) return false;
|
|
18
|
-
const originalValue =
|
|
18
|
+
const originalValue = stripBlankEdges(value);
|
|
19
19
|
return originalValue !== parsedValue && testRegex(regex, originalValue);
|
|
20
20
|
};
|
|
21
21
|
const escapeRegex = (value) => {
|
package/dist/strings.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isString } from "./is.js";
|
|
1
|
+
import { isNonEmptyString, isString } from "./is.js";
|
|
3
2
|
// src/strings.ts
|
|
4
|
-
const blankCharRegex = new RegExp(blankCharacterClass, "u");
|
|
5
3
|
const trimString = (value) => {
|
|
6
4
|
if (!isString(value)) return;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
while (end > start && blankCharRegex.test(value.charAt(end - 1))) end--;
|
|
11
|
-
if (start === end) return;
|
|
12
|
-
return value.slice(start, end);
|
|
5
|
+
const trimmed = value.trim();
|
|
6
|
+
if (!isNonEmptyString(trimmed)) return;
|
|
7
|
+
return trimmed;
|
|
13
8
|
};
|
|
14
9
|
export { trimString };
|
package/dist/urls.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { stripBlankEdges } from "./internal/blank.js";
|
|
1
2
|
import { toPatternList } from "./internal.js";
|
|
2
3
|
import { isFunction, isNullish, isString } from "./is.js";
|
|
3
4
|
import { includesAnyOf, isAnyOf } from "./matching.js";
|
|
4
|
-
import {
|
|
5
|
+
import { setKey } from "./objects.js";
|
|
5
6
|
import { decodeHTMLStrict } from "entities";
|
|
6
7
|
// src/urls.ts
|
|
7
8
|
const httpSchemes = ["http:", "https:"];
|
|
@@ -265,7 +266,7 @@ const readParams = (params, names, options) => {
|
|
|
265
266
|
const picked = {};
|
|
266
267
|
for (const name of names) {
|
|
267
268
|
const value = readParamValues(params, name, options)[0];
|
|
268
|
-
if (value !== void 0) picked
|
|
269
|
+
if (value !== void 0) setKey(picked, name, value);
|
|
269
270
|
}
|
|
270
271
|
return picked;
|
|
271
272
|
};
|
|
@@ -347,7 +348,6 @@ const plusRegex = /\+/g;
|
|
|
347
348
|
const httpSchemeRegex = /^http:\/\//i;
|
|
348
349
|
const httpsSchemeRegex = /^https:\/\//i;
|
|
349
350
|
const repeatedSlashesRegex = /(?<!:|%3a)\/{2,}/gi;
|
|
350
|
-
const pathSlashRunRegex = /^https?:\/\/[^/?#]+(?=\/)[^?#]*\/\//i;
|
|
351
351
|
const leadingWhitespaceChars = [
|
|
352
352
|
" ",
|
|
353
353
|
" ",
|
|
@@ -563,7 +563,7 @@ const upgradeScheme = (url, scheme = "https") => {
|
|
|
563
563
|
return parsed.href;
|
|
564
564
|
};
|
|
565
565
|
const resolveUrl = (url, base) => {
|
|
566
|
-
const trimmedUrl =
|
|
566
|
+
const trimmedUrl = stripBlankEdges(url);
|
|
567
567
|
if (!trimmedUrl) return;
|
|
568
568
|
if (trimmedUrl.startsWith("#") && !base) return;
|
|
569
569
|
let resolvedUrl;
|
|
@@ -632,7 +632,6 @@ const lowercaseQueryPair = (pair) => {
|
|
|
632
632
|
});
|
|
633
633
|
};
|
|
634
634
|
const normalizeUrl = (url, options) => {
|
|
635
|
-
if (options.collapseSlashes && Object.entries(options).every(([key, value]) => key === "collapseSlashes" || !value) && !pathSlashRunRegex.test(url)) return url;
|
|
636
635
|
const parsed = parseUrl(options.normalizeUnicode ? url.normalize("NFC") : url);
|
|
637
636
|
if (!parsed) return url;
|
|
638
637
|
if (options.stripHostTrailingDot && parsed.hostname.endsWith(".")) parsed.hostname = parsed.hostname.slice(0, -1);
|
package/package.json
CHANGED