-
-
Save jed/1182343 to your computer and use it in GitHub Desktop.
isSameOrigin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(){ | |
// will annotate once complete | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(a,b,c){b=document.createElement("a");b.href=a;return(a=location)[c="protocol"]==b[c]&&a[c="hostname"]==b[c]&&+a.port||80==+b.port||80} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "isSameOrigin", | |
"description": "Determines whether a URL has the same origin as the current browser page.", | |
"keywords": [ | |
"url", | |
"uri", | |
"origin", | |
"same-origin", | |
"browser" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<title>Same-origin tester</title> | |
<div>Expected value: <b>true</b></div> | |
<div>Actual value: <b id="ret"></b></div> | |
<script> | |
var myFunction = function(a,b,c){b=document.createElement("a");b.href=a;return(a=location)[c="protocol"]==b[c]&&a[c="hostname"]==b[c]&&+a.port||80==+b.port||80} | |
document.getElementById( "ret" ).innerHTML = myFunction("//gist.github.com:80") | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
127 bytes, use a cached dom link node.
Still does'nt work on IE6 (4.5%) & Safari 4 (lt 0.5%), but both browsers have no/buggy CORS implementation, so who cares?