British Inside

An Englishman living in small town America

James Shaw

News

  • Copyright James Shaw 2004-2007

    Creative Commons License

    View James Shaw's profile on LinkedIn

Kinda Relative URLs

After developing for *cough* some time it's not often that I come across a new style of URL that I've never even heard of before.

A few days ago I saw a forum post about a 404 message someone got about their geotrust smartseal badge. I followed up and found that the javascript that geotrust supply has a URL style that I've never seen before - note below that there is no protocol!

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" src="//smarticon.geotrust.com/si.js"></SCRIPT>

..and two leading //.  

Then I noticed that the Authorize.net badge on the same page was very similar:

<script type="text/javascript" language="javascript"
src
="//VERIFY.AUTHORIZE.NET/anetseal/seal.js" ></script>

Google wasn't helpful for this, but after asking around on some technical lists I got an answer from Adam Sills.

Look at http://www.webreference.com/html/tutorial2/3.html and you'll see that..

"A relative URL that begins with // (two slashes) always replaces everything from the hostname onwards."

You really can learn something every day. This is clever actually, because it means that no matter if your page is being requested as http or https the badges will be requested with the same protocol - meaning that you won't see any security warnings.


 

Posted: Thursday, May 15, 2008 11:23 AM by James
Filed under: ,

Comments

Rich Mercer said:

Wow, I knew reading your blog would pay off one day! That's really cool! :)
# May 15, 2008 9:40 AM

Dan Hounshell said:

Rich, I know what you mean. Seems like you have to wade through 10 tons of dirty coal to find one small diamond, but it's worth it when you do! Just kidding of course, James. :) I have never seen that before either. That is very cool. I'll have to make sure I use that sometime soon.
# May 15, 2008 11:34 AM

James said:

lol. bastards.

# May 15, 2008 11:49 AM
New Comments to this post are disabled