Permalink
Browse files

Merge pull request #5 from Nentuaby/master

Update local link detection to account for relative links (e.g. css/screen.css)
  • Loading branch information...
2 parents a7ff3bb + 0ce54af commit c768238bda227d8f83ea1fc937f893e9dd4b34a1 @philc philc committed Jul 25, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 livecss.js
View
@@ -33,7 +33,7 @@ var livecss = {
var media = (linkElements[i].getAttribute("media") || "").toLowerCase();
if (linkElements[i].getAttribute("rel") == "stylesheet"
&& livecss.indexOf(validMediaTypes, media) >= 0
- && this.isLocalUrl(linkElements[i].getAttribute("href"))) {
+ && this.isLocalLink(linkElements[i])) {
this.refreshLinkElement(linkElements[i]);
}
}
@@ -133,8 +133,11 @@ var livecss = {
return false;
},
- /* returns true for local urls such as: '/screen.css', 'http://mydomain.com/screen.css' */
- isLocalUrl: function(url) {
+ /* returns true for local urls such as: '/screen.css', 'http://mydomain.com/screen.css', 'css/screen.css'
+ */
+ isLocalLink: function(linkElement) {
+ //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);

0 comments on commit c768238

Please sign in to comment.