trousse 3.19.1 → 3.19.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.
Files changed (2) hide show
  1. package/dist/urls.js +15 -11
  2. package/package.json +2 -2
package/dist/urls.js CHANGED
@@ -162,7 +162,7 @@ const decodeBase64 = (value) => {
162
162
  let encoded = "";
163
163
  for (let index = 0; index < binary.length; index++) {
164
164
  const byte = binary.charCodeAt(index);
165
- if (byte < 128 && binary[index] !== "%") {
165
+ if (byte < 128 && !binary.startsWith("%", index)) {
166
166
  encoded += binary[index];
167
167
  continue;
168
168
  }
@@ -183,7 +183,10 @@ const pathSegmentEscapeRegex = /[/?#\\\s]/g;
183
183
  const encodePathSegment = (value) => {
184
184
  return value.replace(pathSegmentEscapeRegex, (character) => encodeURIComponent(character));
185
185
  };
186
- const readRawPairs = (text, prefix) => {
186
+ const decodeFormPart = (part) => {
187
+ return decodePercent(part.replaceAll("+", " "));
188
+ };
189
+ const readPairs = (text, prefix, options) => {
187
190
  if (text === void 0) return;
188
191
  const pairs = [];
189
192
  const body = text.startsWith(prefix) ? text.slice(1) : text;
@@ -191,24 +194,25 @@ const readRawPairs = (text, prefix) => {
191
194
  if (!pair) continue;
192
195
  const separator = pair.indexOf("=");
193
196
  if (separator === -1) {
194
- pairs.push([decodePercent(pair.replaceAll("+", " ")), ""]);
197
+ pairs.push([decodeFormPart(pair), ""]);
195
198
  continue;
196
199
  }
197
- const name = decodePercent(pair.slice(0, separator).replaceAll("+", " "));
198
- pairs.push([name, pair.slice(separator + 1)]);
200
+ const name = decodeFormPart(pair.slice(0, separator));
201
+ const value = pair.slice(separator + 1);
202
+ pairs.push([name, options?.decodeValues === false ? value : decodeFormPart(value)]);
199
203
  }
200
204
  return pairs;
201
205
  };
202
206
  const readQuerySource = (source, options) => {
203
- if (options?.decodeValues === false) return readRawPairs(source instanceof URL ? source.search : source?.toString(), "?");
204
- if (source instanceof URL) return source.searchParams;
205
- if (isString(source)) return new URLSearchParams(source);
207
+ if (options?.decodeValues === false) return readPairs(source instanceof URL ? source.search : source?.toString(), "?", options);
208
+ if (source instanceof URL) return readPairs(source.search, "?", options);
209
+ if (isString(source)) return readPairs(source, "?", options);
206
210
  return source;
207
211
  };
208
212
  const readFragmentSource = (source, options) => {
209
- if (options?.decodeValues === false) return readRawPairs(source instanceof URL ? source.hash : source?.toString(), "#");
210
- if (source instanceof URL) return new URLSearchParams(source.hash.slice(1));
211
- if (isString(source)) return new URLSearchParams(source.startsWith("#") ? source.slice(1) : source);
213
+ if (options?.decodeValues === false) return readPairs(source instanceof URL ? source.hash : source?.toString(), "#", options);
214
+ if (source instanceof URL) return readPairs(source.hash.slice(1), "?", options);
215
+ if (isString(source)) return readPairs(source.startsWith("#") ? source.slice(1) : source, "?", options);
212
216
  return source;
213
217
  };
214
218
  const readParamValues = (params, name, options) => {
package/package.json CHANGED
@@ -40,11 +40,11 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/bun": "^1.4.5",
43
- "kvalita": "^1.41.0",
43
+ "kvalita": "^1.43.0",
44
44
  "tsdown": "0.23.7"
45
45
  },
46
46
  "dependencies": {
47
47
  "entities": "^9.0.0"
48
48
  },
49
- "version": "3.19.1"
49
+ "version": "3.19.3"
50
50
  }