protocol-relative

Scheme relative URL

老子叫甜甜 提交于 2021-02-11 15:59:25
问题 There are a lot of questions on SO regarding scheme relative URL, but I don't understand what will happen in these scenarios: 1) I am on HTTPS clicking on href="//example.com/" (example.com doesn't have SSL (it's HTTP), so browser will try to open HTTPS://example.com/ (because it wants to match the current scheme) and if there won't be HTTPS scheme it will open HTTP://example.com/ ? 2) Vice-versa going from HTTP to HTTPS, when the target //example.com/ is only HTTPS. Will browser open HTTPS

URI starting with two slashes … how do they behave?

孤人 提交于 2020-01-08 09:38:11
问题 Lately I saw working code-blocks like this: <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> And according to RFC 2396 (URI Syntax) and RFC 2616 (HTTP 1.1) these URI starting with two slashes are valid, but unfortunately the RFCs don't really explain them. Can anyone point me to a resource which explains how browsers will/should/do process these URIs? 回答1: The resource you're looking for is the RFC 3986. See Section 4.2 and Section 5.4.

UIWebView doesn't load images from protocol-relative URL

醉酒当歌 提交于 2019-12-22 05:17:33
问题 Make an app with UIWebView which open a webpage with protocol-relative styles & images, such as <img src="//example.com/image.png"> (examples for http or https). Override the page loading process via your custom NSURLConnection , this way. Result: it won't display the images! Though, Safari and other browsers show them correctly... 回答1: I inspected the page opened in WebView and saw weird requests there. They looked like regular URLs, but with applewebdata scheme, e.g. applewebdata://art-u1

gulp-sass compiles Google Fonts CSS into the file, breaks protocol-relative link

有些话、适合烂在心里 提交于 2019-12-21 16:53:11
问题 When I use the following code in my .scss file @import url('//fonts.googleapis.com/css?family=SomeFont:400,700,400italic'); the SASS parser I use (nodejs gulp-sass ) happily downloads the file from said location and includes it as plain text in the compiled output. Here's my Gulpfile: var gulp = require('gulp'), sourcemaps = require('gulp-sourcemaps'), autoprefixer = require('gulp-autoprefixer'), minify = require('gulp-minify-css'), rename = require('gulp-rename'), sass = require('gulp-sass')

Links start with two slashes [duplicate]

梦想与她 提交于 2019-12-17 18:51:07
问题 This question already has answers here : URI starting with two slashes … how do they behave? (4 answers) Closed 6 years ago . More and more, began to notice that the links in the source code on Web sites begin with two slashes. For example: <a href="//example.com/1.png">Image</a> Why do it? 回答1: It's a protocol-relative URL (typically HTTP or HTTPS). So if I'm on http://example.org and I link (or include an image, script, etc.) to //example.com/1.png , it goes to http://example.com/1.png . If

Network-Path Reference URI / Scheme relative URLs

可紊 提交于 2019-12-17 03:00:51
问题 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. 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. 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

What is the expected behavior of a URL preceded with “//” when not linked from an existing page?

戏子无情 提交于 2019-12-11 08:08:32
问题 A nice trick to avoid insecure content warnings on pages that could be either http or https is to reference all scripts or assets in the code using "//" which will use the current page protocol instead of a specified one. If one enters a URL with // in the front directly into a browser URL box, is there a default behavior the browser will pick? Would/should it default to http or https , or some set of rules to test and pick one over the other? 回答1: A network-path reference (e.g., //example

Using protocol-relative URIs within “Location:” headers

爱⌒轻易说出口 提交于 2019-12-09 03:31:08
问题 I note in the PHP manual which states the following: HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. To facilitate users with preference for a HTTPS everywhere connection, I am thinking of changing the headers in my PHP scripts from: header("Location: http://www.example.com/"); to header("Location: //www.example.com/"); I have tested the above code to be working on my firefox browser, but I

Are protocol-relative URLs relative URLs?

…衆ロ難τιáo~ 提交于 2019-12-09 03:07:41
问题 So consider a protocol-relative URL like so; //www.example.com/file.jpg The idea I've had in my head for as long as I can remember is that protocol-relative URLs are in fact absolute URLs. They behave exactly like absolute URLs, and never do they work like relative URLs. I wouldn't expect this to make the browser go find something at http://www.example.com///www.example.com/file.jpg The URL defines the host and the path (like an absolute URL does), and the scheme is inherited from whatever

Why using href=“// instead of href=”http:// in HTML? [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-07 01:09:59
问题 This question already has answers here : Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page (3 answers) Closed 5 years ago . Why using <link href="//something.com/style.css" rel="stylesheet"> instead of using http:// or https:// before the domain name? If we use href=// does it changes with link? Like while in SSL mode will it automatically be changed to https:// ? 回答1: Yes, it will use the current protocol. i.e. if the current page is https it will