Skip to content

Commit

Permalink
Merge pull request #1 from packula/dependabot/npm_and_yarn/packula/re…
Browse files Browse the repository at this point in the history
…gexp-0.2.0
  • Loading branch information
dependabot[bot] authored Mar 25, 2021
2 parents a6c06f0 + 012e236 commit 633d670
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"prepare": "rollup --config rollup.config.js"
},
"dependencies": {
"@packula/regexp": "^0.1.1"
"@packula/regexp": "^0.2.0"
},
"peerDependencies": {
"@packula/router-path": "^0.2.0"
Expand Down
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 633d670

Please sign in to comment.