You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an URIencoded string in my url, Axios automatically decodes the slashes.
To Reproduce
See code snippet
Code snippet
constdeviceId='very/cool/device/å';constencodedDeviceId=encodeURIComponent(deviceId);// very/cool/device/å// the request goes to "http://localhost/search/very/cool/device/å", giving me a 404 erroraxios.get('http://localhost/search/'encodedDeviceId).then(function(response){console.log(response);}).catch(function(error){console.log(error);});
Expected behavior
I would expect Axios to not decode the slashes in my URL, and the request going to http://localhost/search/very/cool/device/å
Axios Version
v0.29.0
Adapter Version
XHR/HTTP
Browser
Firefox, Chromium
Browser Version
132, 131
Node.js Version
v22.10.0
OS
Windows 10, openSUSE Tumbleweed
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered:
Instead of encoding the entire deviceId, you can split the deviceId by / and then encode each part individually and at the end join them by slashes.
This way, the slashes are not encoded in the URL.
Here’s an example:
// Split deviceId by '/' and encode each partconstdeviceId='very/cool/device/å';constdeviceParts=deviceId.split('/').map(encodeURIComponent);constencodedDeviceId=deviceParts.join('/');// very/cool/device/åaxios.get('http://localhost/search/'encodedDeviceId).then(function(response){console.log(response);}).catch(function(error){console.log(error);});
Describe the bug
When using an URIencoded string in my url, Axios automatically decodes the slashes.
To Reproduce
See code snippet
Code snippet
Expected behavior
I would expect Axios to not decode the slashes in my URL, and the request going to
http://localhost/search/very/cool/device/å
Axios Version
v0.29.0
Adapter Version
XHR/HTTP
Browser
Firefox, Chromium
Browser Version
132, 131
Node.js Version
v22.10.0
OS
Windows 10, openSUSE Tumbleweed
Additional Library Versions
No response
Additional context/Screenshots
No response
The text was updated successfully, but these errors were encountered: