[HTTPClient] Incorrect URI encoding for params
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Context
HTTPClient
Current behavior
When adding a param to a HTTP GET request, a colon :
is not encoded to its UTF-8 value %3A
.
Expected behavior
When adding a param to a HTTP GET request, a colon :
is encoded to it’s UTF-8 value %3A
.
Minimal reproduction of the problem with instructions
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { url } from 'config/main';
@Injectable()
export class ExampleService {
constructor(private http: HttpClient) { }
makeRequest(): void {
return this.http.get('http://url.com', {
params: {
param: '$:test',
},
});
}
}
Expected request
http://url.com?param=%24%3atest
Actual request
http://url.com?param=%24:atest
What is the motivation / use case for changing the behavior?
It seems as though the encodeURI function is being used on parameters in order to translate them to UTF-8 strings as opposed to the more appropriate encodeURIComponent function
Environment
Angular version: X.Y.Z
Browser:
- [x] Chrome (desktop) version 64.0.3282.119
Others:
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
c# - HttpClient encoding of URL parameters containing a
and I'm trying to get an entity from a DotNetCore web service by specifying it's id in the URL.
Read more >How To Fix Angular HttpClient Not Escaping URL Parameters
Strangely, I noticed my query parameter was not encoded as expected, which made the API return wrong results. This behaviour might be confusing: ......
Read more >Using URL encoding to handle special characters in a ...
The <space> character needs to be encoded because it is not a valid URL character. Also, some characters, such as "~" might not...
Read more >HTTP Client doesn't url encode plus signs : IDEA-239229
HTTP Client treats + as an encoded space and doesn't encode it the second time. As a workaround you can replace + with...
Read more >URL (GWT Javadoc)
com.google.gwt.http.client.URL ... Parameters: encodedURL - string containing encoded URL encoded sequences; Returns: string with no encoded URL encoded ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m still experiencing this bug on Angular 6.0.3. Isn’t it fixed already?
In my case I’m sending a date string to the server:
2018-06-14T10:20:42+03:00
as a URL param and it doesn’t get encoded at all.I’m having problems with the
+
character.