@ai-sdk/provider-utils 5.0.22 → 5.0.24

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.22",
3
+ "version": "5.0.24",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -36,7 +36,7 @@
36
36
  "@workflow/serde": "4.1.0",
37
37
  "eventsource-parser": "^3.0.8",
38
38
  "undici": "^7.28.0",
39
- "@ai-sdk/provider": "4.0.5"
39
+ "@ai-sdk/provider": "4.0.6"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "22.19.19",
@@ -50,6 +50,23 @@ export function isUrlSupported({
50
50
  })
51
51
  .flatMap(({ regexes }) => regexes)
52
52
  // check if any pattern matches the url:
53
- .some(pattern => pattern.test(url))
53
+ .some(pattern => testRegExpFromStart(pattern, url))
54
54
  );
55
55
  }
56
+
57
+ function testRegExpFromStart(pattern: RegExp, value: string): boolean {
58
+ if (!pattern.global && !pattern.sticky) {
59
+ return pattern.test(value);
60
+ }
61
+
62
+ // Global and sticky regexes retain match state in lastIndex.
63
+ // Evaluate from the start without changing caller-owned state.
64
+ const lastIndex = pattern.lastIndex;
65
+ pattern.lastIndex = 0;
66
+
67
+ try {
68
+ return pattern.test(value);
69
+ } finally {
70
+ pattern.lastIndex = lastIndex;
71
+ }
72
+ }