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..eec6caf54ad5af11c3906f7abbac06c3937e2106 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])), |
|
Søren Gjesse
2013/09/12 09:52:03
With this change the previous change to the RegExp
Anders Johnsen
2013/09/12 10:53:53
Done.
|
| userInfo: _emptyIfNull(m[_COMPONENT_USER_INFO]), |
| host: _eitherOf( |
| m[_COMPONENT_HOST], m[_COMPONENT_HOST_IPV6]), |
| @@ -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()); |
| } |
| } |