Permalink
Browse files

Navigation: Compare domains case-insensitively inside $.mobile.path

(cherry picked from commit ba92be4)

Closes gh-7486
Fixes gh-2446
  • Loading branch information...
1 parent e8c0118 commit b0681280a6e532c1f0f1a56e4a82d6124df5e5b6 @gabrielschulhof gabrielschulhof committed Jun 10, 2014
Showing with 35 additions and 2 deletions.
  1. +5 −2 js/navigation/path.js
  2. +30 −0 tests/unit/path/path_core.js
@@ -154,7 +154,8 @@ define([
//Returns true if both urls have the same domain.
isSameDomain: function( absUrl1, absUrl2 ) {
- return path.parseUrl( absUrl1 ).domain === path.parseUrl( absUrl2 ).domain;
+ return path.parseUrl( absUrl1 ).domain.toLowerCase() ===
+ path.parseUrl( absUrl2 ).domain.toLowerCase();
},
//Returns true for any relative variant.
@@ -262,7 +263,9 @@ define([
//could be mailto, etc
isExternal: function( url ) {
var u = path.parseUrl( url );
- return u.protocol && u.domain !== this.documentUrl.domain ? true : false;
+
+ return !!( u.protocol &&
+ ( u.domain.toLowerCase() !== this.documentUrl.domain.toLowerCase() ) );
},
hasProtocol: function( url ) {
@@ -295,4 +295,34 @@
equal( squash("#foo", "http://example.com/?foo=bar&baz=bak"), "http://example.com/?foo=bar&baz=bak#foo", "ui-state keys attached to simple string hashes are preserved" );
});
+
+ test( "isSameDomain() compares domains case-insensitively", function() {
+ deepEqual(
+ $.mobile.path.isSameDomain(
+ "http://example.com/path/to/filename.html",
+ "http://EXAmPLE.cOm/path/to/filename.html" ),
+ true,
+ "Domain comparison was case-insensitive" );
+ });
+
+( function() {
+
+ var originalDocumentUrl,
+ path = $.mobile.path;
+
+ module( "$.mobile.path.isExternal()", {
+ setup: function() {
+ originalDocumentUrl = path.documentUrl;
+ path.documentUrl = path.parseUrl( "http://example.com/path/to/filename.html" );
+ },
+ teardown: function() {
+ path.documentUrl = originalDocumentUrl;
+ }
+ });
+
+ test( "$.mobile.path.isExternal() compares domains case-insensitively", function() {
+ deepEqual( path.isExternal( "http://EXAmPLE.CoM/path/to/other-filename.html" ), false,
+ "Domain comparison was case-insensitive" );
+ });
+})();
})(jQuery);

0 comments on commit b068128

Please sign in to comment.