Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Ending with an optional parameter breaks expression #1

Closed
nblackburn opened this issue Aug 22, 2016 · 0 comments
Closed

Ending with an optional parameter breaks expression #1

nblackburn opened this issue Aug 22, 2016 · 0 comments
Assignees
Labels

Comments

@nblackburn
Copy link
Owner

Ending a route binding with an optional parameter like the one below, results in the expression breaking.

const {id, action} = match('/users/:id/:action?', '/users/1/delete');

Stacktrace

C:\Users\nblac\Projects\micro-match\source\index.js:46
    return new RegExp(`^${expression}$`);
           ^

SyntaxError: Invalid regular expression: /^/users/([^/]+)/)?([^/]+)?$/: Unmatched ')'
    at RegExp (native)
    at buildExpression (C:\Users\nblac\Projects\micro-match\source\index.js:46:12)
    at match (C:\Users\nblac\Projects\micro-match\source\index.js:92:22)
    at Object.<anonymous> (C:\Users\nblac\Projects\micro-match\source\index.js:102:22)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
@nblackburn nblackburn added the bug label Aug 22, 2016
@nblackburn nblackburn self-assigned this Aug 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant