| OLD | NEW |
| 1 /*! | 1 /*! |
| 2 * Parts of original code from ipv6.js <https://github.com/beaugunderson/javascr
ipt-ipv6> | 2 * Parts of original code from ipv6.js <https://github.com/beaugunderson/javascr
ipt-ipv6> |
| 3 * Copyright 2011 Beau Gunderson | 3 * Copyright 2011 Beau Gunderson |
| 4 * Available under MIT license <http://mths.be/mit> | 4 * Available under MIT license <http://mths.be/mit> |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 const RE_V4 = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|0x[0-9a-f][0-9a-f]?|0
[0-7]{3})\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|0x[0-9a-f][0-9a-f]?|0[0-7
]{3})$/i; | 7 const RE_V4 = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|0x[0-9a-f][0-9a-f]?|0
[0-7]{3})\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|0x[0-9a-f][0-9a-f]?|0[0-7
]{3})$/i; |
| 8 const RE_V4_HEX = /^0x([0-9a-f]{8})$/i; | 8 const RE_V4_HEX = /^0x([0-9a-f]{8})$/i; |
| 9 const RE_V4_NUMERIC = /^[0-9]+$/; | 9 const RE_V4_NUMERIC = /^[0-9]+$/; |
| 10 const RE_V4inV6 = /(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2
[0-4][0-9]|[01]?[0-9][0-9]?)$/; | 10 const RE_V4inV6 = /(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2
[0-4][0-9]|[01]?[0-9][0-9]?)$/; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 { | 151 { |
| 152 // Keep the empty string for invalid URIs. | 152 // Keep the empty string for invalid URIs. |
| 153 } | 153 } |
| 154 | 154 |
| 155 extractHostFromURL._lastURL = url; | 155 extractHostFromURL._lastURL = url; |
| 156 extractHostFromURL._lastDomain = host; | 156 extractHostFromURL._lastDomain = host; |
| 157 return host; | 157 return host; |
| 158 } | 158 } |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * Strips the fragment from a URL. |
| 162 */ |
| 163 function stripFragmentFromURL(/**String*/ url) |
| 164 { |
| 165 return url.replace(/#.*/, ""); |
| 166 } |
| 167 |
| 168 /** |
| 161 * Parses URLs and provides an interface similar to nsIURI in Gecko, see | 169 * Parses URLs and provides an interface similar to nsIURI in Gecko, see |
| 162 * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIURI. | 170 * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIURI. |
| 163 * TODO: Make sure the parsing actually works the same as nsStandardURL. | 171 * TODO: Make sure the parsing actually works the same as nsStandardURL. |
| 164 * @constructor | 172 * @constructor |
| 165 */ | 173 */ |
| 166 function URI(/**String*/ spec) | 174 function URI(/**String*/ spec) |
| 167 { | 175 { |
| 168 this.spec = spec; | 176 this.spec = spec; |
| 169 this._schemeEnd = spec.indexOf(":"); | 177 this._schemeEnd = spec.indexOf(":"); |
| 170 if (this._schemeEnd < 0) | 178 if (this._schemeEnd < 0) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 }, | 255 }, |
| 248 get path() | 256 get path() |
| 249 { | 257 { |
| 250 return this.spec.substring(this._hostPortEnd); | 258 return this.spec.substring(this._hostPortEnd); |
| 251 }, | 259 }, |
| 252 get prePath() | 260 get prePath() |
| 253 { | 261 { |
| 254 return this.spec.substring(0, this._hostPortEnd); | 262 return this.spec.substring(0, this._hostPortEnd); |
| 255 } | 263 } |
| 256 }; | 264 }; |
| OLD | NEW |