diff --git a/src/optional.ts b/src/optional.ts index a03a03c..0a2f1cd 100644 --- a/src/optional.ts +++ b/src/optional.ts @@ -1,5 +1,5 @@ import {AnyParam, NormalizeParam, Param, param, ParamArg, ParamOrString} from '@packula/router-path' -import {escape, unwrap} from '@packula/regexp' +import {escape} from '@packula/regexp' export function optional ( literals: TemplateStringsArray, @@ -18,7 +18,7 @@ export function optional ( // eslint-disable-next-line @typescript-eslint/consistent-type-assertions return { name, - exp: new RegExp(`(?:${escape(start)}${unwrap(exp)}${escape(end)})?`), + exp: new RegExp(`(?:${escape(start)}${exp.source}${escape(end)})?`), build: (arg: Arg) => arg == null ? '' : `${start}${build(arg)}${end}`, parse: match => match === '' ? undefined : parse(match), } as OptionalParam> diff --git a/src/repeating.ts b/src/repeating.ts index 0618f57..637b365 100644 --- a/src/repeating.ts +++ b/src/repeating.ts @@ -1,5 +1,5 @@ import {Param} from '@packula/router-path' -import {escape, unwrap} from '@packula/regexp' +import {escape} from '@packula/regexp' export function any ( name: Name, @@ -32,7 +32,7 @@ export function some ( type SomeParamResult = { [0]: string } & Partial function arrayParamPattern (exp: RegExp, prefix: string, separator: string): string { - const segmentExp = `(?:${unwrap(exp)})` + const segmentExp = `(?:${exp.source})` return `(?:${escape(prefix)}(${segmentExp}(?:${escape(separator)}${segmentExp})*))` }