kenchris / urlpattern-polyfill

URLPattern polyfill
https://www.npmjs.com/package/urlpattern-polyfill
MIT License
268 stars 31 forks source link

Support ".compile" #68

Closed kettanaito closed 2 years ago

kettanaito commented 2 years ago

Thank you for moving so fast with the URLPattern!

I'd like to know if you're planning on supporting a .compile method (referring to the .compile() from path-to-regexp). It'd be great to populate a URL pattern with values:

const pattern = new URLPattern('https://:environment.service.com/:service/:resource')

const url = pattern.compile({
  environment: 'staging',
  service: 'v2',
  resource: '/user'
})

url.toString() // "https://staging.service.com/v2/user"
kettanaito commented 2 years ago

I recall there's been a discussion around this in the design document repo. Please feel free to link to it.

kenchris commented 2 years ago

Feature requests should be filed for the spec repo https://github.com/WICG/urlpattern

wanderview commented 2 years ago

This is already on file at: https://github.com/WICG/urlpattern/issues/73

kettanaito commented 2 years ago

Perfect! Thank you, @kenchris @wanderview!