question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

decodeURI causes server error when uri malformed.

See original GitHub issue

While causing an error itself is fine, but there should be some way to catch the error and possibly do a redirect rather then stopping the execution of the app (this mainly applies to malformed links to the app).

Having it throw an exception as it does is fine by default, but there should be some sort of event that can be used to force a redirect. Likely just from a try/catch on the decodeURI function.

Like so (in nuxt.config.js):

redirectError(url, error) {
   return '/?err_info=' + error.code //could pass some info if possible
}

Though I would think it would be better to keep everything under “redirect” but that would likely lead to a breaking change.

Could add info for things like status code and all that in the return, handling even times when the url might be repairable, just not by decodeURI.

This case mainly comes up from migrating to nuxt from a pre-established site where there might be bad url’s that need to be handled for a time. In the case here, there are 90k pages in the site migrated and this error has been triggered about once a day since launch, it is also seen in Google Search Console so google reads them as valid links on its end but can’t track down the locations of all the links easily. It would be easier to cache the error and redirect that way in my mind.

I plan to eventually do a pull request when I get time, it does not seem like it would be a terribly difficult update to do (and it would get sentry to stop yelling at me lol). Would this be a good way of handling this? Or would there be a better method?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ricardogobbosouzacommented, Feb 19, 2019

I’m working on this feature…

1reaction
jordanramstadcommented, Dec 13, 2018

Should be able to find some time later this month @manniL and I will try to get a PR together then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

URIError: malformed URI sequence - MDN Web Docs - Mozilla
URIError: malformed URI sequence. The JavaScript exception "malformed URI sequence" occurs when URI encoding or decoding wasn't successful.
Read more >
Javascript decodeURI(Component) malformed uri exception
Show activity on this post. I entered the following in Chrome's console: decodeURIComponent('a%AFc'); Instead of resulting to a0xAFc , it caused a URIError ......
Read more >
How to Fix Uncaught URIError: URI malformed Errors in JS
In order to fix "Uncaught URIError: URI malformed" errors in your code, you need to ensure that you are passing valid characters to...
Read more >
JavaScript URIError | Malformed URI Sequence
Cause of the Error: This error is thrown as somewhere in the code, the URI encoding or decoding is unsuccessful.
Read more >
how to solve Unhandled error: URIError: URI malformed
how to solve Unhandled error: URIError: URI malformed ... Have you logged the malformed URIs? ... Server responded with:', body); }) var form...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found