@specific.dev/spectest 0.122.0 → 0.123.0

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/src/url-match.ts CHANGED
@@ -1,13 +1,9 @@
1
1
  // URL pattern matching — shared by `browser.waitForURL(...)` and
2
2
  // `expect(browser).toHaveURL(...)`.
3
3
  //
4
- // Both take the same pattern forms as Playwright (glob string | RegExp |
5
- // predicate over a `URL`), and both lower to `matchesUrl` here so the two
6
- // can never disagree: `waitForURL` hands playwright a predicate that calls
7
- // this rather than letting playwright apply its own glob dialect, and the
8
- // matcher polls it directly. Deliberately dependency-free so `index.ts` (the
9
- // module a project imports on the host, where playwright isn't installed) can
10
- // use it without pulling in `browser.ts`.
4
+ // Both accept glob strings, RegExp, or predicates over a URL. waitForURL
5
+ // uses matchesUrl; the assertion adapter passes regexes/predicates directly
6
+ // to Playwright and compiles string globs with the same globToRegExp helper.
11
7
 
12
8
  /**
13
9
  * How a URL is matched. A **glob string** (`*` stays inside one path segment,
@@ -41,10 +37,10 @@ export function describeUrlPattern(pattern: UrlPattern): string {
41
37
  return JSON.stringify(pattern);
42
38
  }
43
39
 
44
- // Compiled globs are cached: a matcher polls the same pattern every 50ms.
40
+ // Reuse compiled globs across waits and assertions.
45
41
  const GLOB_CACHE = new Map<string, RegExp>();
46
42
 
47
- function globToRegExp(glob: string): RegExp {
43
+ export function globToRegExp(glob: string): RegExp {
48
44
  const hit = GLOB_CACHE.get(glob);
49
45
  if (hit) return hit;
50
46
  let out = "";