| 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 uriTest; | 5 library uriTest; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 testUri(String uriText, bool isAbsolute) { | 10 testUri(String uriText, bool isAbsolute) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 testResolve("http://a/b/c/g#s/./x", "g#s/./x"); | 123 testResolve("http://a/b/c/g#s/./x", "g#s/./x"); |
| 124 testResolve("http://a/b/c/g#s/../x", "g#s/../x"); | 124 testResolve("http://a/b/c/g#s/../x", "g#s/../x"); |
| 125 testResolve("http:g", "http:g"); | 125 testResolve("http:g", "http:g"); |
| 126 | 126 |
| 127 // Additional tests (not from RFC 3986). | 127 // Additional tests (not from RFC 3986). |
| 128 testResolve("http://a/b/g;p/h;s", "../g;p/h;s"); | 128 testResolve("http://a/b/g;p/h;s", "../g;p/h;s"); |
| 129 | 129 |
| 130 // Test non-URI base (no scheme, no authority, relative path). | 130 // Test non-URI base (no scheme, no authority, relative path). |
| 131 base = Uri.parse("a/b/c?_#_"); | 131 base = Uri.parse("a/b/c?_#_"); |
| 132 testResolve("a/b/g?q#f", "g?q#f"); | 132 testResolve("a/b/g?q#f", "g?q#f"); |
| 133 testResolve("./", "../.."); |
| 133 testResolve("../", "../../.."); | 134 testResolve("../", "../../.."); |
| 134 testResolve("a/b/", "."); | 135 testResolve("a/b/", "."); |
| 135 testResolve("c", "../../c"); | 136 testResolve("c", "../../c"); |
| 137 base = Uri.parse("../../a/b/c?_#_"); // Initial ".." in base url. |
| 138 testResolve("../../a/d", "../d"); |
| 139 testResolve("../../../d", "../../../d"); |
| 136 | 140 |
| 137 base = Uri.parse("s:a/b"); | 141 base = Uri.parse("s:a/b"); |
| 138 testResolve("s:/c", "../c"); | 142 testResolve("s:/c", "../c"); |
| 139 } | 143 } |
| 140 | 144 |
| 141 void testResolvePath(String expected, String path) { | 145 void testResolvePath(String expected, String path) { |
| 142 Expect.equals(expected, | 146 Expect.equals(expected, |
| 143 new Uri(path: '/').resolveUri(new Uri(path: path)).path); | 147 new Uri(path: '/').resolveUri(new Uri(path: path)).path); |
| 144 Expect.equals( | 148 Expect.equals( |
| 145 "http://localhost$expected", | 149 "http://localhost$expected", |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 String dump(Uri uri) { | 633 String dump(Uri uri) { |
| 630 return "URI: $uri\n" | 634 return "URI: $uri\n" |
| 631 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" | 635 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" |
| 632 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" | 636 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" |
| 633 " Host: ${uri.host} #${uri.host.length}\n" | 637 " Host: ${uri.host} #${uri.host.length}\n" |
| 634 " Port: ${uri.port}\n" | 638 " Port: ${uri.port}\n" |
| 635 " Path: ${uri.path} #${uri.path.length}\n" | 639 " Path: ${uri.path} #${uri.path.length}\n" |
| 636 " Query: ${uri.query} #${uri.query.length}\n" | 640 " Query: ${uri.query} #${uri.query.length}\n" |
| 637 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; | 641 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; |
| 638 } | 642 } |
| OLD | NEW |