Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/basedomain.js

Issue 8401061: Added handling of $sitekey exceptions (Closed)
Left Patch Set: Created Sept. 24, 2012, 6:15 a.m.
Right Patch Set: Created Sept. 25, 2012, 2:08 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | manifest.json » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 /** 160 /**
161 * Parses URLs and provides an interface similar to nsIURI in Gecko, see 161 * Parses URLs and provides an interface similar to nsIURI in Gecko, see
162 * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIURI. 162 * https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIURI.
163 * TODO: Make sure the parsing actually works the same as nsStandardURL. 163 * TODO: Make sure the parsing actually works the same as nsStandardURL.
164 * @constructor 164 * @constructor
165 */ 165 */
166 function URI(/**String*/ spec) 166 function URI(/**String*/ spec)
167 { 167 {
168 this.spec = spec; 168 this.spec = spec;
Felix Dahlke 2012/09/25 12:40:53 Shouldn't this be this._spec? Seems to be the conv
Wladimir Palant 2012/09/25 14:09:41 It's actually a public member like in nsIURI - tha
169 this._schemeEnd = spec.indexOf(":"); 169 this._schemeEnd = spec.indexOf(":");
Felix Dahlke 2012/09/25 12:40:53 You could probably get rid of a lot of code here i
Wladimir Palant 2012/09/25 14:09:41 Maybe. Then again, that regexp will probably be ab
170 if (this._schemeEnd < 0) 170 if (this._schemeEnd < 0)
171 throw new Error("Invalid URI scheme"); 171 throw new Error("Invalid URI scheme");
172 172
173 if (spec[this._schemeEnd + 1] != "/" || spec[this._schemeEnd + 2] != "/") 173 if (spec.substr(this._schemeEnd + 1, 2) != "//")
Felix Dahlke 2012/09/25 12:40:53 How about this: if (spec.substr(this._schemeEnd +
Wladimir Palant 2012/09/25 14:09:41 Given that we are testing for string equality here
174 throw new Error("Unexpected URI structure"); 174 throw new Error("Unexpected URI structure");
175 175
176 this._hostPortStart = this._schemeEnd + 3; 176 this._hostPortStart = this._schemeEnd + 3;
177 this._hostPortEnd = spec.indexOf("/", this._hostPortStart); 177 this._hostPortEnd = spec.indexOf("/", this._hostPortStart);
178 if (this._hostPortEnd < 0) 178 if (this._hostPortEnd < 0)
179 throw new Error("Invalid URI host"); 179 throw new Error("Invalid URI host");
180 180
181 var authEnd = spec.indexOf("@", this._hostPortStart); 181 var authEnd = spec.indexOf("@", this._hostPortStart);
182 if (authEnd >= 0 && authEnd < this._hostPortEnd) 182 if (authEnd >= 0 && authEnd < this._hostPortEnd)
183 this._hostPortStart = authEnd + 1; 183 this._hostPortStart = authEnd + 1;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 }, 233 },
234 get path() 234 get path()
235 { 235 {
236 return this.spec.substring(this._hostPortEnd); 236 return this.spec.substring(this._hostPortEnd);
237 }, 237 },
238 get prePath() 238 get prePath()
239 { 239 {
240 return this.spec.substring(0, this._hostPortEnd); 240 return this.spec.substring(0, this._hostPortEnd);
241 } 241 }
242 }; 242 };
LEFTRIGHT
« no previous file | manifest.json » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld