|
53 | 53 | matches = path.urlParseRE.exec( url ), |
54 | 54 | results; |
55 | 55 | if ( matches ) { |
| 56 | + // Create an object that allows the caller to access the sub-matches |
| 57 | + // by name. Note that IE returns an empty string instead of undefined, |
| 58 | + // like all other browsers do, so we normalize everything so its consistent |
| 59 | + // no matter what browser we're running on. |
56 | 60 | results = { |
57 | | - href: matches[0], |
58 | | - hrefNoHash: matches[1], |
59 | | - hrefNoSearch: matches[2], |
60 | | - domain: matches[3], |
61 | | - protocol: matches[4], |
62 | | - authority: matches[5], |
63 | | - username: matches[7], |
64 | | - password: matches[8], |
65 | | - host: matches[9], |
66 | | - hostname: matches[10], |
67 | | - port: matches[11], |
68 | | - pathname: matches[12], |
69 | | - directory: matches[13], |
70 | | - filename: matches[14], |
71 | | - search: matches[15], |
72 | | - hash: matches[16] |
| 61 | + href: matches[0] || "", |
| 62 | + hrefNoHash: matches[1] || "", |
| 63 | + hrefNoSearch: matches[2] || "", |
| 64 | + domain: matches[3] || "", |
| 65 | + protocol: matches[4] || "", |
| 66 | + authority: matches[5] || "", |
| 67 | + username: matches[7] || "", |
| 68 | + password: matches[8] || "", |
| 69 | + host: matches[9] || "", |
| 70 | + hostname: matches[10] || "", |
| 71 | + port: matches[11] || "", |
| 72 | + pathname: matches[12] || "", |
| 73 | + directory: matches[13] || "", |
| 74 | + filename: matches[14] || "", |
| 75 | + search: matches[15] || "", |
| 76 | + hash: matches[16] || "" |
73 | 77 | }; |
74 | 78 | } |
75 | 79 | return results || {}; |
|
114 | 118 | //Returns true for any relative variant. |
115 | 119 | isRelativeUrl: function( url ) { |
116 | 120 | // All relative Url variants have one thing in common, no protocol. |
117 | | - return path.parseUrl( url ).protocol === undefined; |
| 121 | + return path.parseUrl( url ).protocol === ""; |
118 | 122 | }, |
119 | 123 |
|
120 | 124 | //Returns true for an absolute url. |
121 | 125 | isAbsoluteUrl: function( url ) { |
122 | | - return path.parseUrl( url ).protocol !== undefined; |
| 126 | + return path.parseUrl( url ).protocol !== ""; |
123 | 127 | }, |
124 | 128 |
|
125 | 129 | //Turn the specified realtive URL into an absolute one. This function |
|
132 | 136 | var relObj = path.parseUrl( relUrl ), |
133 | 137 | absObj = path.parseUrl( absUrl ), |
134 | 138 | protocol = relObj.protocol || absObj.protocol, |
135 | | - authority = relObj.authority || absObj.authority || "", |
136 | | - hasPath = relObj.pathname !== undefined, |
| 139 | + authority = relObj.authority || absObj.authority, |
| 140 | + hasPath = relObj.pathname !== "", |
137 | 141 | pathname = path.makePathAbsolute( relObj.pathname || absObj.filename, absObj.pathname ), |
138 | 142 | search = relObj.search || ( !hasPath && absObj.search ) || "", |
139 | | - hash = relObj.hash || ""; |
| 143 | + hash = relObj.hash; |
140 | 144 |
|
141 | 145 | return protocol + "//" + authority + pathname + search + hash; |
142 | 146 | }, |
|
223 | 227 | //is that links embedded within external documents will refer to the |
224 | 228 | //application document, whereas links embedded within the application |
225 | 229 | //document will be resolved against the document base. |
226 | | - if ( u.protocol !== undefined ) { |
| 230 | + if ( u.protocol !== "" ) { |
227 | 231 | return ( u.hash && ( u.hrefNoHash === documentUrl.hrefNoHash || ( documentBaseDiffers && u.hrefNoHash === documentBase.hrefNoHash ) ) ); |
228 | 232 | } |
229 | 233 | return (/^#/).test( u.href ); |
|
0 commit comments