| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #library('dart:uri'); | 5 #library('dart:uri'); |
| 6 | 6 |
| 7 #import('dart:math'); | 7 #import('dart:math'); |
| 8 #import('dart:utf'); | 8 #import('dart:utf'); |
| 9 | 9 |
| 10 #source('encode_decode.dart'); | 10 #source('encode_decode.dart'); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 bool hasAuthority() { | 171 bool hasAuthority() { |
| 172 return (userInfo != "") || (domain != "") || (port != 0); | 172 return (userInfo != "") || (domain != "") || (port != 0); |
| 173 } | 173 } |
| 174 | 174 |
| 175 /** | 175 /** |
| 176 * For http/https schemes returns URI's [origin][] - scheme://domain:port. | 176 * For http/https schemes returns URI's [origin][] - scheme://domain:port. |
| 177 * For all other schemes throws IllegalArgumentException. | 177 * For all other schemes throws IllegalArgumentException. |
| 178 * [origin]: http://www.w3.org/TR/2011/WD-html5-20110405/origin-0.html#origin | 178 * [origin]: http://www.w3.org/TR/2011/WD-html5-20110405/origin-0.html#origin |
| 179 */ | 179 */ |
| 180 String get origin() { | 180 String get origin { |
| 181 if (scheme == "") { | 181 if (scheme == "") { |
| 182 // TODO(aprelev@gmail.com): Use StateException instead | 182 // TODO(aprelev@gmail.com): Use StateException instead |
| 183 throw new IllegalArgumentException("Cannot use origin without a scheme"); | 183 throw new IllegalArgumentException("Cannot use origin without a scheme"); |
| 184 } | 184 } |
| 185 if (scheme != "http" && scheme != "https") { | 185 if (scheme != "http" && scheme != "https") { |
| 186 // TODO(aprelev@gmail.com): Use StateException instead | 186 // TODO(aprelev@gmail.com): Use StateException instead |
| 187 throw new IllegalArgumentException( | 187 throw new IllegalArgumentException( |
| 188 "origin is applicable to http/https schemes only. Not \'$scheme\'"); | 188 "origin is applicable to http/https schemes only. Not \'$scheme\'"); |
| 189 } | 189 } |
| 190 StringBuffer sb = new StringBuffer(); | 190 StringBuffer sb = new StringBuffer(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 223 } |
| 224 | 224 |
| 225 static void _addIfNonEmpty(StringBuffer sb, String test, | 225 static void _addIfNonEmpty(StringBuffer sb, String test, |
| 226 String first, String second) { | 226 String first, String second) { |
| 227 if ("" != test) { | 227 if ("" != test) { |
| 228 sb.add(first === null ? "null" : first); | 228 sb.add(first === null ? "null" : first); |
| 229 sb.add(second === null ? "null" : second); | 229 sb.add(second === null ? "null" : second); |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 } | 232 } |
| OLD | NEW |