@ai-sdk/provider-utils 5.0.64 → 5.0.65

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider-utils",
3
- "version": "5.0.64",
3
+ "version": "5.0.65",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Encodes a raw identifier as one URL path segment, including standalone dot
3
+ * segments that URL parsers would otherwise normalize. Pass unencoded values;
4
+ * for resource paths with intentional slashes, encode each segment separately.
5
+ */
6
+ export function encodePathSegment(value: string): string {
7
+ const encodedValue = encodeURIComponent(value);
8
+
9
+ // URL parsing normalizes both literal and percent-encoded dot segments.
10
+ return encodedValue === '.'
11
+ ? '%252E'
12
+ : encodedValue === '..'
13
+ ? '%252E%252E'
14
+ : encodedValue;
15
+ }
package/src/index.ts CHANGED
@@ -40,6 +40,7 @@ export {
40
40
  fetchWithValidatedEndpoint,
41
41
  fetchWithValidatedRedirects,
42
42
  } from './fetch-with-validated-redirects';
43
+ export { encodePathSegment } from './encode-path-segment';
43
44
  export { extractLines } from './extract-lines';
44
45
  export * from './extract-response-headers';
45
46
  export * from './fetch-function';
@@ -46,11 +46,12 @@ export function validateDownloadUrl(url: string): void {
46
46
  });
47
47
  }
48
48
 
49
- // Block localhost and .local domains
49
+ // Block localhost and domains reserved for local/private use.
50
50
  if (
51
51
  hostname === 'localhost' ||
52
52
  hostname.endsWith('.local') ||
53
- hostname.endsWith('.localhost')
53
+ hostname.endsWith('.localhost') ||
54
+ hostname.endsWith('.internal')
54
55
  ) {
55
56
  throw new DownloadError({
56
57
  url,