| 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('../../lib/utf/utf.dart'); | 7 #import('../../lib/utf/utf.dart'); |
| 8 #import('../../lib/uri/uri.dart'); | 8 #import('../../lib/uri/uri.dart'); |
| 9 | 9 |
| 10 testUri(String uri, bool isAbsolute) { | 10 testUri(String uri, bool isAbsolute) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 Expect.stringEquals("http://a/b/c/g#s/./x", | 99 Expect.stringEquals("http://a/b/c/g#s/./x", |
| 100 base.resolve("g#s/./x").toString()); | 100 base.resolve("g#s/./x").toString()); |
| 101 Expect.stringEquals("http://a/b/c/g#s/../x", | 101 Expect.stringEquals("http://a/b/c/g#s/../x", |
| 102 base.resolve("g#s/../x").toString()); | 102 base.resolve("g#s/../x").toString()); |
| 103 Expect.stringEquals("http:g", base.resolve("http:g").toString()); | 103 Expect.stringEquals("http:g", base.resolve("http:g").toString()); |
| 104 | 104 |
| 105 // Additional tests (not from RFC 3986). | 105 // Additional tests (not from RFC 3986). |
| 106 Expect.stringEquals("http://a/b/g;p/h;s", | 106 Expect.stringEquals("http://a/b/g;p/h;s", |
| 107 base.resolve("../g;p/h;s").toString()); | 107 base.resolve("../g;p/h;s").toString()); |
| 108 | 108 |
| 109 Expect.stringEquals( |
| 110 "http://example.com", |
| 111 new Uri.fromString("http://example.com/a/b/c").origin); |
| 112 Expect.stringEquals( |
| 113 "https://example.com", |
| 114 new Uri.fromString("https://example.com/a/b/c").origin); |
| 115 Expect.stringEquals( |
| 116 "http://example.com:1234", |
| 117 new Uri.fromString("http://example.com:1234/a/b/c").origin); |
| 118 Expect.stringEquals( |
| 119 "https://example.com:1234", |
| 120 new Uri.fromString("https://example.com:1234/a/b/c").origin); |
| 121 Expect.stringEquals("http:", const Uri("http", null, null).origin); |
| 122 Expect.stringEquals("http://:80", const Uri("http", null, null, 80).origin); |
| 123 |
| 124 var expectedException = null; |
| 125 try { |
| 126 var s = const Uri("file://").origin; |
| 127 } catch (IllegalArgumentException e) { |
| 128 expectedException = e; |
| 129 } |
| 130 Expect.isNotNull(expectedException, "origin for non-http/https should fail"); |
| 131 |
| 109 // URI encode tests | 132 // URI encode tests |
| 110 // Note: dart2js won't handle '\ud800\udc00' and frog | 133 // Note: dart2js won't handle '\ud800\udc00' and frog |
| 111 // won't handle '\u{10000}'. So we cons this up synthetically... | 134 // won't handle '\u{10000}'. So we cons this up synthetically... |
| 112 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]); | 135 var s = decodeUtf8([0xf0, 0x90, 0x80, 0x80]); |
| 113 | 136 |
| 114 testEncodeDecode("\uFFFE", "%EF%BF%BE"); | 137 testEncodeDecode("\uFFFE", "%EF%BF%BE"); |
| 115 testEncodeDecode("\uFFFF", "%EF%BF%BF"); | 138 testEncodeDecode("\uFFFF", "%EF%BF%BF"); |
| 116 testEncodeDecode("\uFFFE", "%EF%BF%BE"); | 139 testEncodeDecode("\uFFFE", "%EF%BF%BE"); |
| 117 testEncodeDecode("\uFFFF", "%EF%BF%BF"); | 140 testEncodeDecode("\uFFFF", "%EF%BF%BF"); |
| 118 testEncodeDecode("\x7f", "%7F"); | 141 testEncodeDecode("\x7f", "%7F"); |
| 119 testEncodeDecode("\x80", "%C2%80"); | 142 testEncodeDecode("\x80", "%C2%80"); |
| 120 testEncodeDecode("\u0800", "%E0%A0%80"); | 143 testEncodeDecode("\u0800", "%E0%A0%80"); |
| 121 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=+\$"); | 144 testEncodeDecode(":/@',;?&=+\$", ":/@',;?&=+\$"); |
| 122 testEncodeDecode(s, "%F0%90%80%80"); | 145 testEncodeDecode(s, "%F0%90%80%80"); |
| 123 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); | 146 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); |
| 124 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); | 147 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); |
| 125 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); | 148 testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); |
| 126 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); | 149 testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); |
| 127 testEncodeDecodeComponent("\x7f", "%7F"); | 150 testEncodeDecodeComponent("\x7f", "%7F"); |
| 128 testEncodeDecodeComponent("\x80", "%C2%80"); | 151 testEncodeDecodeComponent("\x80", "%C2%80"); |
| 129 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); | 152 testEncodeDecodeComponent("\u0800", "%E0%A0%80"); |
| 130 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); | 153 testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); |
| 131 testEncodeDecodeComponent(s, "%F0%90%80%80"); | 154 testEncodeDecodeComponent(s, "%F0%90%80%80"); |
| 132 } | 155 } |
| OLD | NEW |