• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

422
Views
React routes param auto decode string

Hi does react router params automatically decodes string?

For example i have this route

<Route path="/callback/:url"/>

and when I call it with C5jb20%3D

it will print C5jb20= when I console.log() that parameters

Is this an expected behavior? Can I change this behavior so that I still get the encoded string?

Thanks!

over 3 years ago · Santiago Trujillo
1 answers
Answer question

0

C5jb20%3D is a URL encoded string, which is a way to encode special characters in a URL. For example, if you have a URL parameter like ?redirect=/some/path, a server could interpret the forward slashes as routing paths, and mess up the expected routing. That's why you see things like ?redirect=%2Fsome%2Fpath, and your example, in URLs.

window.location.path will have the original, unencoded URL.

You could also get it back with encodeURIComponent:

encodeURIComponent('C5jb20=') // "C5jb20%3D"

You probably don't want to, though, depending on your use case.

over 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error