Skip to content

Commit

Permalink
Replace usage of removed @packula/regexp unwrap function
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Mar 25, 2021
1 parent 8bf6b89 commit 012e236
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/optional.ts
Original file line number Diff line number Diff line change
@@ -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<InnerParam extends ParamOrString> (
literals: TemplateStringsArray,
Expand All @@ -18,7 +18,7 @@ export function optional<InnerParam extends ParamOrString> (
// 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<NormalizeParam<InnerParam>>
Expand Down
4 changes: 2 additions & 2 deletions src/repeating.ts
Original file line number Diff line number Diff line change
@@ -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 extends string> (
name: Name,
Expand Down Expand Up @@ -32,7 +32,7 @@ export function some<Name extends string> (
type SomeParamResult = { [0]: string } & Partial<string[]>

function arrayParamPattern (exp: RegExp, prefix: string, separator: string): string {
const segmentExp = `(?:${unwrap(exp)})`
const segmentExp = `(?:${exp.source})`

return `(?:${escape(prefix)}(${segmentExp}(?:${escape(separator)}${segmentExp})*))`
}

0 comments on commit 012e236

Please sign in to comment.