query-string 9.5.0 → 9.5.1
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/base.js +8 -3
- package/package.json +1 -1
package/base.js
CHANGED
|
@@ -579,9 +579,14 @@ export function stringifyUrl(object, options) {
|
|
|
579
579
|
|
|
580
580
|
let hash = getHash(object.url);
|
|
581
581
|
if (typeof object.fragmentIdentifier === 'string') {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
582
|
+
hash = `#${object.fragmentIdentifier}`;
|
|
583
|
+
|
|
584
|
+
if (options[encodeFragmentIdentifier]) {
|
|
585
|
+
// Percent-encode the fragment with a throwaway URL. The fragment percent-encode set does not depend on the scheme, so the caller's URL is deliberately not parsed here; it may not even be parseable.
|
|
586
|
+
const throwawayUrl = new URL('https://query-string.invalid');
|
|
587
|
+
throwawayUrl.hash = hash;
|
|
588
|
+
hash = throwawayUrl.hash;
|
|
589
|
+
}
|
|
585
590
|
}
|
|
586
591
|
|
|
587
592
|
return `${url}${queryString}${hash}`;
|