Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(619)

Unified Diff: sdk/lib/core/uri.dart

Issue 23766030: Return the correct port from Uri, when port is 0 and scheme is either http or https. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
}
« no previous file with comments | « no previous file | tests/co19/co19-co19.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698