fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Edge case request - ability to opt out of urlencoding #233

Closed brad-decker closed 1 year ago

brad-decker commented 6 years ago

https://www.redfin.com/city/30818/TX/Austin/filter/min-price=100k,max-price=325k

I am building something that updates the state of the url based on a set of filters, Redfin's site is almost an exact match to my intended effect. The last 'route' portion is the /filter/ and everything after that are a series of filters that we are parsing and can be in any combination or order

Do you have a suggestion for how I can achieve this with next-routes? We are already using it but the problem is everything after filter/ gets urlencoded which produces some very ugly urls.

dekkofilms commented 6 years ago

+1

HeyHugo commented 6 years ago

Was looking into a similar case for nextjs before (comma separated querystring values getting uri encoded).

I believe the encoding and url formatting is done by a dependecy of nextjs: https://www.npmjs.com/package/url

Anyways I decided to just use _ as separator for now. Here you can see what character are not encoded by encodeURIComponent

brad-decker commented 6 years ago

@HeyHugo https://github.com/fridays/next-routes/blob/master/src/index.js#L172 is where the encoding is happening, i think. Do you feel differently?

HeyHugo commented 6 years ago

Ah you're right. I didn't check so carefully and assumed it was using the Router.push / Router.replace of nextjs which I found was using the url package.

ellioseven commented 5 years ago

@brad-decker Did you ever find a solution for this? I am in the same situation and can't seem to find a graceful way around the encoding.

DonStanislas commented 5 years ago

+1