| 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 uri, bool isAbsolute) { | 10 testUri(String uri, bool isAbsolute) { |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 new Uri(scheme: "scheme", path: "/").toString()); | 360 new Uri(scheme: "scheme", path: "/").toString()); |
| 361 | 361 |
| 362 Expect.equals("scheme:///?#", Uri.parse("scheme:///?#").toString()); | 362 Expect.equals("scheme:///?#", Uri.parse("scheme:///?#").toString()); |
| 363 Expect.equals("scheme:///#", | 363 Expect.equals("scheme:///#", |
| 364 new Uri(scheme: "scheme", host: "", path: "/", | 364 new Uri(scheme: "scheme", host: "", path: "/", |
| 365 query: "", fragment: "").toString()); | 365 query: "", fragment: "").toString()); |
| 366 } | 366 } |
| 367 | 367 |
| 368 main() { | 368 main() { |
| 369 testUri("http:", true); | 369 testUri("http:", true); |
| 370 testUri("file://", true); | 370 testUri("file:///", true); |
| 371 testUri("file", false); | 371 testUri("file", false); |
| 372 testUri("http://user@example.com:8080/fisk?query=89&hest=silas", true); | 372 testUri("http://user@example.com:8080/fisk?query=89&hest=silas", true); |
| 373 testUri("http://user@example.com:8080/fisk?query=89&hest=silas#fragment", | 373 testUri("http://user@example.com:8080/fisk?query=89&hest=silas#fragment", |
| 374 false); | 374 false); |
| 375 Expect.stringEquals("http://user@example.com/a/b/c?query#fragment", | 375 Expect.stringEquals("http://user@example.com/a/b/c?query#fragment", |
| 376 new Uri( | 376 new Uri( |
| 377 scheme: "http", | 377 scheme: "http", |
| 378 userInfo: "user", | 378 userInfo: "user", |
| 379 host: "example.com", | 379 host: "example.com", |
| 380 port: 80, | 380 port: 80, |
| 381 path: "/a/b/c", | 381 path: "/a/b/c", |
| 382 query: "query", | 382 query: "query", |
| 383 fragment: "fragment").toString()); | 383 fragment: "fragment").toString()); |
| 384 Expect.stringEquals("/a/b/c/", | 384 Expect.stringEquals("/a/b/c/", |
| 385 new Uri( | 385 new Uri( |
| 386 scheme: null, | 386 scheme: null, |
| 387 userInfo: null, | 387 userInfo: null, |
| 388 host: null, | 388 host: null, |
| 389 port: 0, | 389 port: 0, |
| 390 path: "/a/b/c/", | 390 path: "/a/b/c/", |
| 391 query: null, | 391 query: null, |
| 392 fragment: null).toString()); | 392 fragment: null).toString()); |
| 393 Expect.stringEquals("file://", Uri.parse("file:").toString()); | 393 Expect.stringEquals("file:///", Uri.parse("file:").toString()); |
| 394 | 394 |
| 395 testResolvePath("/a/g", "/a/b/c/./../../g"); | 395 testResolvePath("/a/g", "/a/b/c/./../../g"); |
| 396 testResolvePath("/a/g", "/a/b/c/./../../g"); | 396 testResolvePath("/a/g", "/a/b/c/./../../g"); |
| 397 testResolvePath("/mid/6", "mid/content=5/../6"); | 397 testResolvePath("/mid/6", "mid/content=5/../6"); |
| 398 testResolvePath("/a/b/e", "a/b/c/d/../../e"); | 398 testResolvePath("/a/b/e", "a/b/c/d/../../e"); |
| 399 testResolvePath("/a/b/e", "../a/b/c/d/../../e"); | 399 testResolvePath("/a/b/e", "../a/b/c/d/../../e"); |
| 400 testResolvePath("/a/b/e", "./a/b/c/d/../../e"); | 400 testResolvePath("/a/b/e", "./a/b/c/d/../../e"); |
| 401 testResolvePath("/a/b/e", "../a/b/./c/d/../../e"); | 401 testResolvePath("/a/b/e", "../a/b/./c/d/../../e"); |
| 402 testResolvePath("/a/b/e", "./a/b/./c/d/../../e"); | 402 testResolvePath("/a/b/e", "./a/b/./c/d/../../e"); |
| 403 testResolvePath("/a/b/e/", "./a/b/./c/d/../../e/."); | 403 testResolvePath("/a/b/e/", "./a/b/./c/d/../../e/."); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 String dump(Uri uri) { | 534 String dump(Uri uri) { |
| 535 return "URI: $uri\n" | 535 return "URI: $uri\n" |
| 536 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" | 536 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" |
| 537 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" | 537 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" |
| 538 " Host: ${uri.host} #${uri.host.length}\n" | 538 " Host: ${uri.host} #${uri.host.length}\n" |
| 539 " Port: ${uri.port}\n" | 539 " Port: ${uri.port}\n" |
| 540 " Path: ${uri.path} #${uri.path.length}\n" | 540 " Path: ${uri.path} #${uri.path.length}\n" |
| 541 " Query: ${uri.query} #${uri.query.length}\n" | 541 " Query: ${uri.query} #${uri.query.length}\n" |
| 542 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; | 542 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; |
| 543 } | 543 } |
| OLD | NEW |