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.

Is it possible to encode the URL before fire up the request?

e.g:

$scope.user.getList(‘cars’); //would fires users/123/cars.

Let say, the user’s id contains characters like: ~!@#$&*()=:/,;?+', and I want to encode before sending. E.g:roy#01.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RichardBradleycommented, May 20, 2016

I think this is a bug, and restangular should url-encode supplied entity IDs before using them to construct REST urls.

You said:

$http encodes the Request Parameters as tey need to be encoded. It doesn’t encode the rest of the URL and for a good reason. Maybe you actually want to go to a URL with a # which is entirely possible.

… but this is not comparable, because the argument to $http is a URL, whereas the argument to restangular functions like getList is an entity ID. It is correct for angularJS to not url-encode a URL typed argument, as that would result in double-encoding, as you point out. However, it is incorrect for restangular to not URL encode a String value when using it in a URL.

0reactions
RichardBradleycommented, May 23, 2016

Actually, I think the bug I am experiencing is in ng-admin, sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML URL Encoding Reference - W3Schools
Character From Windows‑1252 From UTF‑8 space %20 %20 ! %21 %21 " %22 %22
Read more >
URL Encode and Decode - Online
Encode to URL-encoded format or decode from it with various advanced options. Our site has an easy to use online tool to convert...
Read more >
Percent-encoding - Wikipedia
Percent -encoding, also known as URL encoding, is a method to encode arbitrary data in a Uniform Resource Identifier (URI) using only the...
Read more >
URL Decoder/Encoder - meyerweb.com
Input a string of text and encode or decode it as you like. Handy for turning encoded JavaScript URLs from complete gibberish into...
Read more >
URL Encoding | Google Maps Platform
All characters to be URL-encoded are encoded using a '%' character and a two-character hex value corresponding to their UTF-8 character. For example,...
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