X-Git-Url: https://git.ayoreis.com/relax.git/blobdiff_plain/82fcd505c9fc789a85a86f34b51848109a66fa46..83524f5609ef938630538f11371a2d0a4b88035f:/relax/url-pattern-list.ts?ds=inline diff --git a/relax/url-pattern-list.ts b/relax/url-pattern-list.ts index 55451a0..802d02a 100644 --- a/relax/url-pattern-list.ts +++ b/relax/url-pattern-list.ts @@ -1,4 +1,8 @@ -import { compareComponent } from "./url-pattern-compare-component.ts"; +import compare_component from "./url-pattern-compare-component.ts"; + +export interface URLPatternListResult extends URLPatternResult { + pattern: URLPattern; +} export const COMPONENTS = [ "hash", @@ -12,13 +16,13 @@ export const COMPONENTS = [ ] as const; /** https://github.com/whatwg/urlpattern/issues/30 */ -export class URLPatternList { +export default class { readonly #patterns; constructor(patterns: Iterable) { this.#patterns = Array.from(patterns).sort((left, right) => { for (const component of COMPONENTS) { - const order = compareComponent(component, left, right); + const order = compare_component(component, left, right); if (order !== 0) return order; } @@ -34,7 +38,7 @@ export class URLPatternList { for (const pattern of this.#patterns) { const result = pattern.exec(input, baseURL); if (result === null) continue; - yield { pattern, ...result }; + yield { pattern, ...result } satisfies URLPatternListResult; } } }