diff --git a/src/Path.ts b/src/Path.ts index 2e7159e..38e0ecf 100644 --- a/src/Path.ts +++ b/src/Path.ts @@ -329,7 +329,7 @@ export class Path = Record> { private getParams(type: string | RegExp): string[] { const predicate = - type instanceof RegExp + typeof type !== 'string' ? (t: Token) => type.test(t.type) : (t: Token) => t.type === type diff --git a/src/tokeniser.ts b/src/tokeniser.ts index af7b215..f330a6e 100644 --- a/src/tokeniser.ts +++ b/src/tokeniser.ts @@ -21,7 +21,7 @@ const tokenise = (str: string, tokens: Token[] = []): Token[] => { match: match[0], val: match.slice(1, 2), otherVal: match.slice(2), - regex: rule.regex instanceof Function ? rule.regex(match) : rule.regex + regex: typeof rule.regex === 'function' ? rule.regex(match) : rule.regex }) if (match[0].length < str.length) {