Skip to content

Commit

Permalink
Simplified code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Ross committed Jul 14, 2011
1 parent 83f2390 commit 0ce54af
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions livecss.js
Expand Up @@ -133,16 +133,11 @@ var livecss = {
return false;
},

/* returns true for local urls such as: '/screen.css', 'http://mydomain.com/screen.css'
May miss relative urls such as 'css/screen.css' on older browsers
/* returns true for local urls such as: '/screen.css', 'http://mydomain.com/screen.css', 'css/screen.css'
*/
isLocalLink: function(linkElement) {
var url = null;
//On all tested browsers, this javascript property returns a normalized URL
if(linkElement.href) url = linkElement.href;
//Fallback if the above property is nonexistant (probably an elderly IE). Note that this will provide EXACTLY the attribute set, it will not be normalized as above.
//This will produce a false negative on entirely relative urls, e.g. "css/default.css"
else url = linkElement.getAttribute("href");
//On all tested browsers, this javascript property returns a normalized URL
var url = linkElement.href;
var regexp = new RegExp("^\/|^" +
document.location.protocol + "//" + document.location.host);
return (url.search(regexp) == 0);
Expand Down

0 comments on commit 0ce54af

Please sign in to comment.