Chromium Code Reviews| Index: sdk/lib/core/uri.dart |
| diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart |
| index f80a30018e9e14680c63fd30b9aebbe8f952d9b3..bafc8501b5f92901f222e228139db8c0187fbe46 100644 |
| --- a/sdk/lib/core/uri.dart |
| +++ b/sdk/lib/core/uri.dart |
| @@ -63,7 +63,13 @@ class Uri { |
| * |
| * Returns 0 if there is no port in the authority component. |
| */ |
| - int get port => _port; |
| + int get port { |
| + if (_port == 0) { |
| + if (scheme == "http") return 80; |
| + if (scheme == "https") return 443; |
| + } |
| + return _port; |
| + } |
| /** |
| * Returns the path component. |
| @@ -107,7 +113,7 @@ class Uri { |
| static Uri parse(String uri) => new Uri._fromMatch(_splitRe.firstMatch(uri)); |
| Uri._fromMatch(Match m) : |
| - this(scheme: _emptyIfNull(m[_COMPONENT_SCHEME]), |
| + this(scheme: _makeScheme(_emptyIfNull(m[_COMPONENT_SCHEME])), |
| userInfo: _emptyIfNull(m[_COMPONENT_USER_INFO]), |
| host: _eitherOf( |
| m[_COMPONENT_HOST], m[_COMPONENT_HOST_IPV6]), |
| @@ -710,7 +716,7 @@ class Uri { |
| static final RegExp _splitRe = new RegExp( |
| '^' |
| '(?:' |
| - '([^:/?#.]+)' // scheme - ignore special characters |
| + '([^:/?#]+)' // scheme - ignore special characters |
|
Søren Gjesse
2013/09/12 13:03:14
Re-align comment.
Anders Johnsen
2013/09/12 13:25:23
Done.
|
| // used by other URL parts such as :, |
| // ?, /, #, and . |
| ':)?' |
| @@ -875,8 +881,8 @@ class Uri { |
| throw new StateError( |
| "Origin is only applicable schemes http and https: $this"); |
| } |
| - if (port == 0) return "$scheme://$_host"; |
| - return "$scheme://$_host:$port"; |
| + if (_port == 0) return "$scheme://$_host"; |
| + return "$scheme://$_host:$_port"; |
| } |
| /** |
| @@ -1008,9 +1014,9 @@ class Uri { |
| void _writeAuthority(StringSink ss) { |
| _addIfNonEmpty(ss, userInfo, userInfo, "@"); |
| ss.write(_host == null ? "null" : _host); |
| - if (port != 0) { |
| + if (_port != 0) { |
| ss.write(":"); |
| - ss.write(port.toString()); |
| + ss.write(_port.toString()); |
| } |
| } |