| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 345 |
| 346 uri = new Uri(scheme: "file", path: "//y"); | 346 uri = new Uri(scheme: "file", path: "//y"); |
| 347 Expect.equals("//y", uri.path); | 347 Expect.equals("//y", uri.path); |
| 348 Expect.equals("file:////y", uri.toString()); | 348 Expect.equals("file:////y", uri.toString()); |
| 349 | 349 |
| 350 // File scheme noralizes to always showing authority, even if empty. | 350 // File scheme noralizes to always showing authority, even if empty. |
| 351 uri = new Uri(scheme: "file", path: "/y"); | 351 uri = new Uri(scheme: "file", path: "/y"); |
| 352 Expect.equals("file:///y", uri.toString()); | 352 Expect.equals("file:///y", uri.toString()); |
| 353 uri = new Uri(scheme: "file", path: "y"); | 353 uri = new Uri(scheme: "file", path: "y"); |
| 354 Expect.equals("file:///y", uri.toString()); | 354 Expect.equals("file:///y", uri.toString()); |
| 355 | |
| 356 // Empty host/query/fragment ensures the delimiter is there. | |
| 357 // Different from not being there. | |
| 358 Expect.equals("scheme:/", Uri.parse("scheme:/").toString()); | |
| 359 Expect.equals("scheme:/", | |
| 360 new Uri(scheme: "scheme", path: "/").toString()); | |
| 361 | |
| 362 Expect.equals("scheme:///?#", Uri.parse("scheme:///?#").toString()); | |
| 363 Expect.equals("scheme:///?#", | |
| 364 new Uri(scheme: "scheme", host: "", path: "/", | |
| 365 query: "", fragment: "").toString()); | |
| 366 } | 355 } |
| 367 | 356 |
| 368 main() { | 357 main() { |
| 369 testUri("http:", true); | 358 testUri("http:", true); |
| 370 testUri("file://", true); | 359 testUri("file://", true); |
| 371 testUri("file", false); | 360 testUri("file", false); |
| 372 testUri("http://user@example.com:8080/fisk?query=89&hest=silas", true); | 361 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", | 362 testUri("http://user@example.com:8080/fisk?query=89&hest=silas#fragment", |
| 374 false); | 363 false); |
| 375 Expect.stringEquals("http://user@example.com/a/b/c?query#fragment", | 364 Expect.stringEquals("http://user@example.com/a/b/c?query#fragment", |
| 376 new Uri( | 365 new Uri( |
| 377 scheme: "http", | 366 scheme: "http", |
| 378 userInfo: "user", | 367 userInfo: "user", |
| 379 host: "example.com", | 368 host: "example.com", |
| 380 port: 80, | 369 port: 80, |
| 381 path: "/a/b/c", | 370 path: "/a/b/c", |
| 382 query: "query", | 371 query: "query", |
| 383 fragment: "fragment").toString()); | 372 fragment: "fragment").toString()); |
| 384 Expect.stringEquals("/a/b/c/", | 373 Expect.stringEquals("//null@null/a/b/c/", |
| 385 new Uri( | 374 new Uri( |
| 386 scheme: null, | 375 scheme: null, |
| 387 userInfo: null, | 376 userInfo: null, |
| 388 host: null, | 377 host: null, |
| 389 port: 0, | 378 port: 0, |
| 390 path: "/a/b/c/", | 379 path: "/a/b/c/", |
| 391 query: null, | 380 query: null, |
| 392 fragment: null).toString()); | 381 fragment: null).toString()); |
| 393 Expect.stringEquals("file://", Uri.parse("file:").toString()); | 382 Expect.stringEquals("file://", Uri.parse("file:").toString()); |
| 394 | 383 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 String dump(Uri uri) { | 523 String dump(Uri uri) { |
| 535 return "URI: $uri\n" | 524 return "URI: $uri\n" |
| 536 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" | 525 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" |
| 537 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" | 526 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" |
| 538 " Host: ${uri.host} #${uri.host.length}\n" | 527 " Host: ${uri.host} #${uri.host.length}\n" |
| 539 " Port: ${uri.port}\n" | 528 " Port: ${uri.port}\n" |
| 540 " Path: ${uri.path} #${uri.path.length}\n" | 529 " Path: ${uri.path} #${uri.path.length}\n" |
| 541 " Query: ${uri.query} #${uri.query.length}\n" | 530 " Query: ${uri.query} #${uri.query.length}\n" |
| 542 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; | 531 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; |
| 543 } | 532 } |
| OLD | NEW |