trousse 2.16.2 → 2.16.3
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/is.js +1 -1
- package/dist/urls.js +4 -6
- package/package.json +2 -2
package/dist/is.js
CHANGED
|
@@ -25,7 +25,7 @@ const isPlainObject = (value) => {
|
|
|
25
25
|
};
|
|
26
26
|
const whitespaceOnlyRegex = /^\p{White_Space}*$/u;
|
|
27
27
|
const isNonEmptyString = (value) => {
|
|
28
|
-
if (!isString(value) || value
|
|
28
|
+
if (!isString(value) || !value) return false;
|
|
29
29
|
const code = value.charCodeAt(0);
|
|
30
30
|
if (code > 32 && code < 127) return true;
|
|
31
31
|
return !whitespaceOnlyRegex.test(value);
|
package/dist/urls.js
CHANGED
|
@@ -183,11 +183,9 @@ const httpOrSchemeRelativeRegex = /^(?:https?:)?\/\//i;
|
|
|
183
183
|
const slugTailRegex = /[/.-]/;
|
|
184
184
|
const lostSeparatorRegex = /(?<!\s)\s+(?=[A-Za-z_][\w.-]*=)/g;
|
|
185
185
|
const slashClosedValueRegex = /(=[^&/=]+)\/+(?=&|$)/g;
|
|
186
|
-
const isGlueTail = (head, glueIndex, pathEnd
|
|
186
|
+
const isGlueTail = (head, glueIndex, pathEnd) => {
|
|
187
187
|
const tail = head.slice(glueIndex + 1, pathEnd).split("&")[0] ?? "";
|
|
188
|
-
|
|
189
|
-
if (slugTailRegex.test(tail)) return false;
|
|
190
|
-
return head.slice(glueIndex + 1, ownEnd).includes("=");
|
|
188
|
+
return tail.includes("=") || !slugTailRegex.test(tail);
|
|
191
189
|
};
|
|
192
190
|
const fixMalformedQuery = (url) => {
|
|
193
191
|
if (!httpOrSchemeRelativeRegex.test(url)) return url;
|
|
@@ -204,7 +202,7 @@ const fixMalformedQuery = (url) => {
|
|
|
204
202
|
const pathIndex = head.indexOf("/", authorityEnd);
|
|
205
203
|
const pathEnd = hasMark ? markIndex : ownEnd;
|
|
206
204
|
const glueIndex = pathIndex !== -1 && pathIndex < pathEnd ? head.indexOf("&", pathIndex) : -1;
|
|
207
|
-
const isGlued = glueIndex !== -1 && glueIndex < pathEnd && isGlueTail(head, glueIndex, pathEnd
|
|
205
|
+
const isGlued = glueIndex !== -1 && glueIndex < pathEnd && isGlueTail(head, glueIndex, pathEnd);
|
|
208
206
|
if (!isGlued && !hasMark) return url;
|
|
209
207
|
const queryIndex = isGlued ? glueIndex : markIndex;
|
|
210
208
|
const queryStart = queryIndex + (isGlued && head[glueIndex + 1] === "?" ? 2 : 1);
|
|
@@ -380,7 +378,7 @@ const normalizeUrl = (url, options) => {
|
|
|
380
378
|
parsed.search = pairs.join("&");
|
|
381
379
|
}
|
|
382
380
|
if (options.sortQueryParams && parsed.search.includes("&")) parsed.search = parsed.search.slice(1).split("&").filter(Boolean).sort(compareQueryPairs).join("&");
|
|
383
|
-
if (options.stripEmptyQuery && parsed.search
|
|
381
|
+
if (options.stripEmptyQuery && !parsed.search) parsed.search = "";
|
|
384
382
|
let result = parsed.href;
|
|
385
383
|
if (options.stripRootSlash && result === `${parsed.origin}/`) result = parsed.origin;
|
|
386
384
|
if (options.stripScheme ?? options.stripProtocol) result = result.replace(schemePrefixRegex, "");
|
package/package.json
CHANGED