"点"在查询字符串参数 - AngularJS [英] "dot" in query string parameter - AngularJS
问题描述
我想用点(。)中的查询字符串参数,但它不工作。
此URL是工作的罚款:
<一个href=\"http://localhost:9000/search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=com\" rel=\"nofollow\">http://localhost:9000/search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=com
但不是这一个,因为它含有参数的点:
<一个href=\"http://localhost:9000/search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=co.uk\" rel=\"nofollow\">http://localhost:9000/search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=co.uk
当我试图打开上述网址(与点),它只是打印:
不能得到/search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=co.uk
和闲来无事,甚至没有任何HTML标记(已检查,在查看源代码)
我看了很多帖子它说的。可以在查询字符串中使用没有编码,但我不明白为什么它不是在这里工作。我认为这与AngularJS一些问题。
我使用状态变化 UI路由器并传递价值的控制器。
任何帮助将是AP preciated。
如果您使用的是连史-API的后备您的服务器上(确实喜欢精简版服务器) ,以点的URL默认情况下不重写。
<一个href=\"https://github.com/bripkens/connect-history-api-fallback/blob/e5bc77c5b1e3c9d07647764675971d262e773ac9/lib/index.js#L59-l67\"相对=nofollow>连接 - 历史-API的后备code
如果(parsedUrl.pathname.indexOf('。')!== -1){
记录器(
不改写,
req.method,
req.url,
因为路径包括一个点(。)字符。
);
返回下一个();
}
与启动连接 - 历史-API的后备
版本 1.2.0 的<一个href=\"https://github.com/bripkens/connect-history-api-fallback/commit/7dbc0bddd37eaa21fa71f4167939f59dc14367c9\"相对=nofollow>用点网址可以并可以解决的这个问题通过使用AA 重写鲁莱 的p>
示例
如果用点您的网址是 /搜索结果
和你的角度应用生命中的<$ C $ C> index.html的页您可以添加重写规则到这样的连接 - 历史-API的后备
重写:
{
来自:/ ^ \\ /搜索结果/,
到:的index.html'
}
}
]
I'm trying to use dot (.) in query string parameter but its not working.
This URL is working fine:
But not this one as it contains a dot in a parameter:
When I'm trying to open above URL (with dot), it just prints:
Cannot GET /search-result?majTFMin=0&majTFMax=100&majDOMCFMin=0&majDOMCFMax=100&majRefDomainsMin=0&majRefDomainsMax=100&majRefIPsMin=0&majRefIPsMax=100&majRefDomainsEDUMin=0&majRefDomainsEDUMax=100&majRefDomainsGOVMin=0&majRefDomainsGOVMax=100&selectedTLDs=co.uk
And nothing else, not even any HTML tags(has checked that in view source)
I have read lots of posts which says that . can be used in query string without encoding, but I don't understand why its not working here. I think it has some issue with AngularJS.
I'm using ui-router for state change and passed value to controller.
Any help would be appreciated.
If you are using connect-history-api-fallback on your server (like lite-server does), the URLs with a dot are not rewritten by default.
connect-history-api-fallback code
if (parsedUrl.pathname.indexOf('.') !== -1) {
logger(
'Not rewriting',
req.method,
req.url,
'because the path includes a dot (.) character.'
);
return next();
}
Starting with connect-history-api-fallback
version 1.2.0 the URLs with dots are allowed and you can solve this problem by using a a rewrite roule
Example
If your URL with dot is /search-result
and you angular app lives in the index.html
page you can add a rewrite rule to the connect-history-api-fallback like this
rewrites: [
{
from: /^\/search-result/,
to: 'index.html'
}
}
]
这篇关于&QUOT;点&QUOT;在查询字符串参数 - AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!