url-pattern icon indicating copy to clipboard operation
url-pattern copied to clipboard

Support for curly brackets url syntax

Open danday74 opened this issue 6 years ago • 4 comments

I understand most libraries use:

/users/:id

but Swagger, the no1 lib for defining API contracts and mocking, uses:

/users/{id}

I need to parse the Swagger-style syntax.

This is a request for that support to be added.

Thanks

danday74 avatar Mar 29 '18 16:03 danday74

this could be solved cleanly by adding and implementing an optional segmentNameEndChar option.

then one should be able to configure url-pattern with the following options to do what you want:

{
  segmentNameStartChar: "{",
  segmentNameEndChar: "}",
}

i don't have time to do that right now. going to wait to see whether there is more demand for this.

snd avatar Apr 01 '18 03:04 snd

Can I take up this issue? Are you looking to accept a PR for this?

arpitsingh94 avatar Apr 29 '19 19:04 arpitsingh94

hey @arpitsingh94,

i'm in the process of converting url-pattern from coffeescript to typescript on this branch: https://github.com/snd/url-pattern/tree/coffeescript-to-typescript

the code conversion is done and the tests still pass. i just need to adapt the rest of the repo to it. once that is complete you're very welcome to tackle this issue.

i'll post a note here once the conversion is complete

snd avatar Apr 29 '19 20:04 snd

ok sure.

arpitsingh94 avatar Apr 30 '19 16:04 arpitsingh94