I am trying to send .
(dot) as a string to the following aspi call in Nodejs. I am using Angularjs $http
object.
我想发送。 (点)作为Nodejs中以下aspi调用的字符串。我正在使用Angularjs $ http对象。
I can see that the call is being made with the dot (.) character that I have entered in the search box.
我可以看到使用我在搜索框中输入的点(。)字符进行调用。
https://localhost:3003/posts/search/.
However, when I see the ajax call through google developer tool, it is making a call as:
但是,当我通过谷歌开发者工具看到ajax电话时,它正在拨打电话:
https://localhost:3003/posts/search/
How can I pass a dot character?
我怎样才能传递点字符?
code is:
return
$http.get('https://localhost:3003/posts/search/.').then(getPostCompleted).catch(function (message) {
handleException(message);
});
I don't think I have to btoa or atob on this?
我认为我不需要btoa或atob吗?
Thanks Am
3 个解决方案
#1
You should use get params using something like :
您应该使用以下内容来使用get params:
https://localhost:3003/posts/search?req=.
and get the req
params in your code. I know it's not the route your wanted but i think that the dot is a special character that coulnd't be use in the route because it is use for the domain
并在您的代码中获取req参数。我知道这不是你想要的路线,但我认为这个点是一个特殊的角色,不能在路线中使用,因为它用于域名
#2
How can I pass a dot character?
我怎样才能传递点字符?
String in URLs mush be url-encoded. Raw javascript has a function that does this, but angular.js $http service has special behavior for this.
URL中的字符串是url编码的。原始javascript具有执行此操作的功能,但angular.js $ http服务具有此特殊行为。
EDIT :
I can see that the call is being made with the dot (.) character that I have entered in the search box.
我可以看到使用我在搜索框中输入的点(。)字符进行调用。
https://localhost:3003/posts/search/.
However, when I see the ajax call through google developer tool, it is making a call as:
但是,当我通过谷歌开发者工具看到ajax电话时,它正在拨打电话:
Chrome must be stripping dots without extension by default. A regex parsing it somewhere maybe.
默认情况下,Chrome必须在不扩展的情况下剥离点。一个正则表达式解析它可能在某处。
#3
See this about using a dot.
请参阅有关使用点的信息。
If you want to use GET then you could pass the parameter as a query string i.e
如果你想使用GET,那么你可以将参数作为查询字符串传递,即
$http.get('https://localhost:3003/posts/search?string=.')
.then(getPostCompleted).catch(function (message) {
handleException(message);
});
Otherwise you can use POST and add the parameter to the body
否则,您可以使用POST并将参数添加到正文
$http.post('https://localhost:3003/posts/search', {string: '.'})
.then(getPostCompleted).catch(function (message) {
handleException(message);
});
#1
You should use get params using something like :
您应该使用以下内容来使用get params:
https://localhost:3003/posts/search?req=.
and get the req
params in your code. I know it's not the route your wanted but i think that the dot is a special character that coulnd't be use in the route because it is use for the domain
并在您的代码中获取req参数。我知道这不是你想要的路线,但我认为这个点是一个特殊的角色,不能在路线中使用,因为它用于域名
#2
How can I pass a dot character?
我怎样才能传递点字符?
String in URLs mush be url-encoded. Raw javascript has a function that does this, but angular.js $http service has special behavior for this.
URL中的字符串是url编码的。原始javascript具有执行此操作的功能,但angular.js $ http服务具有此特殊行为。
EDIT :
I can see that the call is being made with the dot (.) character that I have entered in the search box.
我可以看到使用我在搜索框中输入的点(。)字符进行调用。
https://localhost:3003/posts/search/.
However, when I see the ajax call through google developer tool, it is making a call as:
但是,当我通过谷歌开发者工具看到ajax电话时,它正在拨打电话:
Chrome must be stripping dots without extension by default. A regex parsing it somewhere maybe.
默认情况下,Chrome必须在不扩展的情况下剥离点。一个正则表达式解析它可能在某处。
#3
See this about using a dot.
请参阅有关使用点的信息。
If you want to use GET then you could pass the parameter as a query string i.e
如果你想使用GET,那么你可以将参数作为查询字符串传递,即
$http.get('https://localhost:3003/posts/search?string=.')
.then(getPostCompleted).catch(function (message) {
handleException(message);
});
Otherwise you can use POST and add the parameter to the body
否则,您可以使用POST并将参数添加到正文
$http.post('https://localhost:3003/posts/search', {string: '.'})
.then(getPostCompleted).catch(function (message) {
handleException(message);
});