网络路径参考URI /方案相对URL [英] Network-Path Reference URI / Scheme relative URLs

查看:343
本文介绍了网络路径参考URI /方案相对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方案相对URL(网络路径引用)的东西,我只是发现了约 - 您不指定URL的方案,从目前的背景下它捡起

Scheme relative URLs (network-path references) are something that I've just found out about - where you don't specify the scheme of a URL and it picks it up from the current context.

例如:
< IMG SRC =// domain.com/img.png/> 将解析为 https://domain.com/img巴纽如果当前的方案是HTTPS或 http://domain.com/img.png 如果事实并非如此。

For example: <img src="//domain.com/img.png" /> will resolve to https://domain.com/img.png if the current scheme is HTTPS or http://domain.com/img.png if it is not.

这似乎是一个非常简单的方法来解决调用一个SSL页面上的外部脚本或图像而不会弹出可怕的错误页面上的一些内容是不是安全的那些烦人的问题。

This seems like a very easy way to resolve those pesky problems of calling an external script or image on an SSL page without bringing up the dreaded error that some content on a page is not secure.

这样做的好处似乎是显而易见的,但我似乎并没有能够找到是一个巨大的这个信息量,并想知道如果任何人有任何经验或有关方案相对URL引用(好或坏)?

The benefit seems obvious, but what I don't seem to be able to find is a huge amount of information on this and was wondering if anyone had any experience or references about scheme relative URLs (good or bad)?

虽然我试图发现是否有此出现问题的原因(我已经成功的IE6-8,Chrome和Firefox)浏览器的任何,我也有兴趣,看看是否有人使用有什么经验这不同的语言。例如,它会工作,如果你要发出的Response.Redirect 在ASP的计划相对URL?

Whilst I'm trying to discover if there are any browsers that this causes issues with (I've been successful with IE6-8, Chrome and Firefox), I'm also interested to find out if anyone has any experience using this in different languages. For example, would it work if you were to issue a Response.Redirect with a scheme relative URL in ASP?

推荐答案

// domain.com/img.png 是一个完全有效的URI语法按的 RFC 3986:第4.2节

//domain.com/img.png is a perfectly valid URI syntax as per RFC 3986: Section 4.2.

有相对于当前方案和因此如你所提到的,它可以是间的http切换时非常有用和https,因为你不会需要明确指定的方案。

It is relative to the current scheme, and therefore as you mentioned, it can be very useful when switching between http and https, because you won't need to explicitly specify the scheme.

所有现代浏览器会明白的格式,包括IE 6。

All modern browsers will understand that format, including IE 6.

进一步阅读堆栈溢出:

这篇关于网络路径参考URI /方案相对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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