Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle % and # characters on parameter #256

Closed
PenguinScola opened this issue Nov 15, 2018 · 3 comments
Closed

How to handle % and # characters on parameter #256

PenguinScola opened this issue Nov 15, 2018 · 3 comments

Comments

@PenguinScola
Copy link

I am developing tag tracking system on NextJS and my application URL need to receive parameter as tag name that contains % and # characters. For example, "C#", "100%" etc.

So its URL will look like below.

https://myapp.com/tag/C#
https://myapp.com/tag/100%
https://myapp.com/tag/harry_potter

For "C#", I have found that query value from getInitialProps function will be "C" only (# character is cut)
and for "100%", I have found that next-routes return error as below. URI malformed has occurred on decodeURIComponent function because of % character.

image

If I need to handle both of characters, could you please suggest how can I handle them by using next-routes?

@karolisgrinkevicius
Copy link

I'm having the same question as @PenguinScola.

@nagibmahfuj
Copy link

Any solution to this issue, I'm also having this problem :(

@nagibmahfuj
Copy link

nagibmahfuj commented Dec 3, 2019

Lastly I did this to resolve on my server.js file.

const server = express();
server.use(function(req, res, next) {
    try {
        decodeURIComponent(req.originalUrl);
    } catch (err) {
        res.redirect(301, "/");
        next(err);
    }
});
// Do other stuffs
server.use(handler).listen(3000);

@fridays fridays closed this as completed Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants