|
| 1 | +// We use a custom type definition for this due to https://github.com/kenchris/urlpattern-polyfill/issues/135. |
| 2 | +// Without this, this conflicts with the v24 Node.js type definitions. This would still cause big problems if |
| 3 | +// we expose URLPattern in any of our own APIs & type definitions, but fortunately we don't (at time of writing) |
| 4 | + |
| 5 | +export type URLPatternInput = URLPatternInit | string; |
| 6 | + |
| 7 | +export declare class URLPattern { |
| 8 | + constructor(init?: URLPatternInput, baseURL?: string); |
| 9 | + |
| 10 | + test(input?: URLPatternInput, baseURL?: string): boolean; |
| 11 | + |
| 12 | + exec(input?: URLPatternInput, baseURL?: string): URLPatternResult | null; |
| 13 | + |
| 14 | + readonly protocol: string; |
| 15 | + readonly username: string; |
| 16 | + readonly password: string; |
| 17 | + readonly hostname: string; |
| 18 | + readonly port: string; |
| 19 | + readonly pathname: string; |
| 20 | + readonly search: string; |
| 21 | + readonly hash: string; |
| 22 | +} |
| 23 | + |
| 24 | +interface URLPatternInit { |
| 25 | + baseURL?: string; |
| 26 | + username?: string; |
| 27 | + password?: string; |
| 28 | + protocol?: string; |
| 29 | + hostname?: string; |
| 30 | + port?: string; |
| 31 | + pathname?: string; |
| 32 | + search?: string; |
| 33 | + hash?: string; |
| 34 | +} |
| 35 | + |
| 36 | +export interface URLPatternResult { |
| 37 | + inputs: [URLPatternInput]; |
| 38 | + protocol: URLPatternComponentResult; |
| 39 | + username: URLPatternComponentResult; |
| 40 | + password: URLPatternComponentResult; |
| 41 | + hostname: URLPatternComponentResult; |
| 42 | + port: URLPatternComponentResult; |
| 43 | + pathname: URLPatternComponentResult; |
| 44 | + search: URLPatternComponentResult; |
| 45 | + hash: URLPatternComponentResult; |
| 46 | +} |
| 47 | + |
| 48 | +export interface URLPatternComponentResult { |
| 49 | + input: string; |
| 50 | + groups: { |
| 51 | + [key: string]: string | undefined; |
| 52 | + }; |
| 53 | +} |
0 commit comments