如何避免$ location.url的URL解码? [英] How to avoid url decoding of $location.url?
问题描述
我的角度$位置
我有一间codeD URL,如 VAR蛞蝓='测试 - 测试/ 7%2F8测试';
。我使用 $ location.url(塞)
来重定向但不幸的是它会去codeD,当涉及到浏览器中。
I have an encoded URL such as var slug = 'test-test/7%2F8-test';
. I am using $location.url(slug)
to redirect but unfortunately it gets decoded when it comes to the browser.
同样的EN codeD URL应在浏览器中看到的。
The same encoded URL should seen in the browser.
在浏览器中的当前行为是: www.test.com/test-test/7/8-test
预期的行为是: www.test.com/test-test/7%2F8-test
The current behavior in the browser is: www.test.com/test-test/7/8-test
Expected behavior is: www.test.com/test-test/7%2F8-test
但是当我使用路径它会连接再次codeD。
But when I use path it gets encoded again.
任何帮助吗?
我猜 $ location.ur()
默认情况下,对其进行解码。就如何克服这个问题的任何帮助吗?
I guess $location.ur()
is decoding it by default. Any help on how to overcome this problem?
https://github.com/angular/angular.js/blob/master/src/ng/location.js#L388
我的另一个担心是,而其get德codeD自动进入直接连接codeD网址于浏览器。
My another concern is while entering the direct encoded URL on the browser its get decoded automatically.
推荐答案
使用JavaScript的香草?
Use vanilla javascript?
document.location = "http://www.google.com/test%fdsfsd";
将维持'%'
标志..
这篇关于如何避免$ location.url的URL解码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!