gvergnaud / nextjs-dynamic-routes

[Deprecated] Super simple way to create dynamic routes with Next.js
MIT License
140 stars 7 forks source link

Consider using path-to-regexp's compile function #16

Open lydell opened 5 years ago

lydell commented 5 years ago

Like in this branch: https://github.com/gvergnaud/nextjs-dynamic-routes/tree/use-pathtoregexp

This way advanced URL patterns such as :foo+ and :digits(\d+) can be supported.

https://github.com/pillarjs/path-to-regexp#compile-reverse-path-to-regexp

gvergnaud commented 5 years ago

Yep as you can see I was planing on migrating to path-to-regexp, but I didn't manage to make it work on my first try for some reason. I agree it would be nice to finish this. I'll have a look. Of course, you are welcome to open a PR for this :)

lydell commented 5 years ago

One thing that stopped me from making a PR is that the functions returned by compile throw errors when given invalid/missing data, while today’s implementation seems to never throw errors. So we need to decide what the API should look like (does it throw errors?) and if it’s a breaking change etc.