如果一个浏览器连接code自定义URI启动一个应用程序之前? [英] Should a browser encode a custom URI before launching an app?

查看:205
本文介绍了如果一个浏览器连接code自定义URI启动一个应用程序之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大干快上一个自定义的URI看起来像的myapp推出一个应用程序://什么/什么

I have an app which gets launched on a custom URI which looks like myapp://whatever/something

有是具有HREF链接,因为这一个HTML页面 - > 的myapp://不论/ X = ABC; Y = PQR;
当这个被点击铬的myapp获取URL 的myapp://不论/ X = ABC%3By%3Dpqr%3B ,网址获得EN codeD?
然而,当我点击默认的Internet浏览器相同的链路上 - 没有进行编码。它得到的原始URL - > 的myapp://不论/ X = ABC; Y = PQR;

There is a HTML page which has a href link as this -> myapp://whatever/?x=abc;y=pqr; When this is clicked in chrome, myapp gets the URL myapp://whatever/?x=abc%3By%3Dpqr%3B, the URL gets encoded However when I click on the same link on the default Internet browser - no encoding is done. It gets the original URL -> myapp://whatever/?x=abc;y=pqr;

什么是正确的行为?

我试图在Android 4.4.3本使用Chrome 38.0.2125.114。另外,我觉得早期版本的Chrome浏览器并没有做到这一点,但不那么肯定。

I tried this using Chrome 38.0.2125.114 on Android 4.4.3. Also, I think earlier versions of Chrome didn't do this, but not so sure.

推荐答案

在网址分号治疗是不完全一致,所以最好的办法是正确,清楚地逃脱你的网址。

Treatment of semicolons in URLs isn't totally consistent, so your best approach is to escape your URL correctly and unambiguously.

如果您打算设置 X 的值 ABC单查询参数; Y = PQR; 然后逃脱的形式是正确的:

If you intend to set a single query parameter of x to the value abc;y=pqr; then the escaped form is correct:

?x=abc%3By%3Dpqr%3B

然而,如果你打算单独的参数,那么&安培; 将是互操作性更好的选择。如果要指定 X ABC 作为 PQR 那么你应该将其指定为:

However, if you intend separate parameters then & would be a better choice for interoperability. If you want to specify x as abc and y as pqr then you should specify this as:

?x=abc&y=pqr

如您所见,浏览器的行为是不是predictable与转义分号,所以避免它们。

As you've seen, browser behaviour is not predictable with unescaped semicolons, so avoid them.

这篇关于如果一个浏览器连接code自定义URI启动一个应用程序之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆