Skip to content

Commit

Permalink
implement hasRegExpGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyroman authored and kenchris committed Nov 25, 2023
1 parent a6eb2b2 commit e136cc4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/url-pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ export class URLPattern {
#names: string[] = {};
#component_pattern: any = {};
#parts: any = {};
#hasRegExpGroups: boolean = false;

constructor(init: URLPatternInit | string, baseURL?: string, options?: URLPatternOptions);
constructor(init: URLPatternInit | string, options?: URLPatternOptions);
Expand Down Expand Up @@ -449,6 +450,8 @@ export class URLPattern {
this.#parts[component] = parse(pattern as string, options);
this.#regexp[component] = partsToRegexp(this.#parts[component], /* out */ this.#names[component], options);
this.#component_pattern[component] = partsToPattern(this.#parts[component], options);
this.#hasRegExpGroups = this.#hasRegExpGroups ||
this.#parts[component].some((p: Part) => p.type === PartType.kRegex);
} catch (err) {
// If a pattern is illegal the constructor will throw an exception
throw new TypeError(`invalid ${component} pattern '${this.#pattern[component]}'.`);
Expand Down Expand Up @@ -680,4 +683,8 @@ export class URLPattern {
public get hash() {
return this.#component_pattern.hash;
}

public get hasRegExpGroups() {
return this.#hasRegExpGroups;
}
}

0 comments on commit e136cc4

Please sign in to comment.