Skip to content

Instantly share code, notes, and snippets.

@radmiraal
Created August 1, 2012 20:09
Show Gist options
  • Save radmiraal/3230269 to your computer and use it in GitHub Desktop.
Save radmiraal/3230269 to your computer and use it in GitHub Desktop.
var isLocal = (function() {
var rhash = /#.*$/,
currentPage = location.href.replace( rhash, "" );
return function( anchor ) {
// clone the node to work around IE 6 not normalizing the href property
// if it's manually set, i.e., a.href = "#foo" kills the normalization
anchor = anchor.cloneNode( false );
return anchor.hash.length > 1 &&
anchor.href.replace( rhash, "" ) === currentPage;
};
})();
var isLocal = (function() {
var rhash = /#.*$/,
currentPage = location.href.replace( rhash, "" );
return function( anchor ) {
var href = anchor.href.replace(location.origin + '/', location.href);
// clone the node to work around IE 6 not normalizing the href property
// if it's manually set, i.e., a.href = "#foo" kills the normalization
anchor = anchor.cloneNode( false );
return anchor.hash.length > 1 &&
href.replace( rhash, "" ) === currentPage;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment