9d6a64e81b
This merges the dart:uri library into dart:core removing the dart:uri library. Besides moving the library the Url class has been changed. * Removed existing Uri constructor as it was equivalent with Uri.parse * Remamed constructor Uri.fromComponents to Uri * Moved toplevel function encodeUriComponent to static method Uri.encodeComponent * Moved toplevel function decodeUriComponent to static method Uri.decodeComponent * Moved toplevel function encodeUri to static method Uri.encodeFull * Moved toplevel function decodeUri to static method Uri.decodeFull * Rename domain to host * Added static methods Uri.encodeQueryComponent and Uri.decodeQueryComponent * Added support for path generation and splitting * Added support for query generation and splitting * Added some level of normalization R=floitsch@google.com, lrn@google.com, nweiz@google.com, scheglov@google.com BUG= Review URL: https://codereview.chromium.org//16019002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23266 260f80e4-7a28-3924-810f-c04153c831b5
43 lines
1.2 KiB
Dart
43 lines
1.2 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
testNormalizePath() {
|
|
test(String expected, String path) {
|
|
var uri = new Uri(path: path);
|
|
Expect.equals(expected, uri.path);
|
|
Expect.equals(expected, uri.toString());
|
|
}
|
|
|
|
var unreserved = "-._~0123456789"
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
"abcdefghijklmnopqrstuvwxyz";
|
|
|
|
test("A", "%41");
|
|
test("AB", "%41%42");
|
|
test("%40AB", "%40%41%42");
|
|
test("a", "%61");
|
|
test("ab", "%61%62");
|
|
test("%60ab", "%60%61%62");
|
|
test(unreserved, unreserved);
|
|
|
|
var x = new StringBuffer();
|
|
for (int i = 32; i < 128; i++) {
|
|
if (unreserved.indexOf(new String.fromCharCode(i)) != -1) {
|
|
x.writeCharCode(i);
|
|
} else {
|
|
x.write("%");
|
|
x.write(i.toRadixString(16));
|
|
}
|
|
}
|
|
print(x.toString().toUpperCase());
|
|
Expect.equals(x.toString().toUpperCase(),
|
|
new Uri(path: x.toString()).toString().toUpperCase());
|
|
}
|
|
|
|
main() {
|
|
testNormalizePath();
|
|
}
|