| 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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'dart:uri'; | |
| 7 | 6 |
| 8 | 7 |
| 9 void testValidIpv6Uri() { | 8 void testValidIpv6Uri() { |
| 10 var path = 'http://[::1]:1234/path?query=5#now'; | 9 var path = 'http://[::1]:1234/path?query=5#now'; |
| 11 var uri = Uri.parse(path); | 10 var uri = Uri.parse(path); |
| 12 Expect.equals('http', uri.scheme); | 11 Expect.equals('http', uri.scheme); |
| 13 Expect.equals('::1', uri.domain); | 12 Expect.equals('::1', uri.host); |
| 14 Expect.equals(1234, uri.port); | 13 Expect.equals(1234, uri.port); |
| 15 Expect.equals('/path', uri.path); | 14 Expect.equals('/path', uri.path); |
| 16 Expect.equals('query=5', uri.query); | 15 Expect.equals('query=5', uri.query); |
| 17 Expect.equals('now', uri.fragment); | 16 Expect.equals('now', uri.fragment); |
| 18 Expect.equals(path, uri.toString()); | 17 Expect.equals(path, uri.toString()); |
| 19 | 18 |
| 19 path = 'http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:8080/index.html'; |
| 20 uri = Uri.parse(path); |
| 21 Expect.equals('http', uri.scheme); |
| 22 Expect.equals('FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', uri.host); |
| 23 Expect.equals(8080, uri.port); |
| 24 Expect.equals('/index.html', uri.path); |
| 25 Expect.equals(path, uri.toString()); |
| 26 |
| 20 path = 'http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html'; | 27 path = 'http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html'; |
| 21 uri = Uri.parse(path); | 28 uri = Uri.parse(path); |
| 22 Expect.equals('http', uri.scheme); | 29 Expect.equals('http', uri.scheme); |
| 23 Expect.equals('FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', uri.domain); | 30 Expect.equals('FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', uri.host); |
| 24 Expect.equals(80, uri.port); | 31 Expect.equals(0, uri.port); |
| 25 Expect.equals('/index.html', uri.path); | 32 Expect.equals('/index.html', uri.path); |
| 26 Expect.equals(path, uri.toString()); | 33 Expect.equals('http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]/index.html', |
| 34 uri.toString()); |
| 35 |
| 36 path = 'https://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:443/index.html'; |
| 37 uri = Uri.parse(path); |
| 38 Expect.equals('https', uri.scheme); |
| 39 Expect.equals('FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', uri.host); |
| 40 Expect.equals(0, uri.port); |
| 41 Expect.equals('/index.html', uri.path); |
| 42 Expect.equals('https://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]/index.html', |
| 43 uri.toString()); |
| 27 | 44 |
| 28 path = 'http://[1080:0:0:0:8:800:200C:417A]/index.html'; | 45 path = 'http://[1080:0:0:0:8:800:200C:417A]/index.html'; |
| 29 uri = Uri.parse(path); | 46 uri = Uri.parse(path); |
| 30 Expect.equals('http', uri.scheme); | 47 Expect.equals('http', uri.scheme); |
| 31 Expect.equals('1080:0:0:0:8:800:200C:417A', uri.domain); | 48 Expect.equals('1080:0:0:0:8:800:200C:417A', uri.host); |
| 32 Expect.equals(0, uri.port); | 49 Expect.equals(0, uri.port); |
| 33 Expect.equals('/index.html', uri.path); | 50 Expect.equals('/index.html', uri.path); |
| 34 Expect.equals(path, uri.toString()); | 51 Expect.equals(path, uri.toString()); |
| 35 | 52 |
| 36 path = 'http://[3ffe:2a00:100:7031::1]'; | 53 path = 'http://[3ffe:2a00:100:7031::1]'; |
| 37 uri = Uri.parse(path); | 54 uri = Uri.parse(path); |
| 38 Expect.equals('http', uri.scheme); | 55 Expect.equals('http', uri.scheme); |
| 39 Expect.equals('3ffe:2a00:100:7031::1', uri.domain); | 56 Expect.equals('3ffe:2a00:100:7031::1', uri.host); |
| 40 Expect.equals(0, uri.port); | 57 Expect.equals(0, uri.port); |
| 41 Expect.equals('', uri.path); | 58 Expect.equals('', uri.path); |
| 42 Expect.equals(path, uri.toString()); | 59 Expect.equals(path, uri.toString()); |
| 43 | 60 |
| 44 path = 'http://[1080::8:800:200C:417A]/foo'; | 61 path = 'http://[1080::8:800:200C:417A]/foo'; |
| 45 uri = Uri.parse(path); | 62 uri = Uri.parse(path); |
| 46 Expect.equals('http', uri.scheme); | 63 Expect.equals('http', uri.scheme); |
| 47 Expect.equals('1080::8:800:200C:417A', uri.domain); | 64 Expect.equals('1080::8:800:200C:417A', uri.host); |
| 48 Expect.equals(0, uri.port); | 65 Expect.equals(0, uri.port); |
| 49 Expect.equals('/foo', uri.path); | 66 Expect.equals('/foo', uri.path); |
| 50 Expect.equals(path, uri.toString()); | 67 Expect.equals(path, uri.toString()); |
| 51 | 68 |
| 52 path = 'http://[::192.9.5.5]/ipng'; | 69 path = 'http://[::192.9.5.5]/ipng'; |
| 53 uri = Uri.parse(path); | 70 uri = Uri.parse(path); |
| 54 Expect.equals('http', uri.scheme); | 71 Expect.equals('http', uri.scheme); |
| 55 Expect.equals('::192.9.5.5', uri.domain); | 72 Expect.equals('::192.9.5.5', uri.host); |
| 56 Expect.equals(0, uri.port); | 73 Expect.equals(0, uri.port); |
| 57 Expect.equals('/ipng', uri.path); | 74 Expect.equals('/ipng', uri.path); |
| 58 Expect.equals(path, uri.toString()); | 75 Expect.equals(path, uri.toString()); |
| 59 | 76 |
| 77 path = 'http://[::FFFF:129.144.52.38]:8080/index.html'; |
| 78 uri = Uri.parse(path); |
| 79 Expect.equals('http', uri.scheme); |
| 80 Expect.equals('::FFFF:129.144.52.38', uri.host); |
| 81 Expect.equals(8080, uri.port); |
| 82 Expect.equals('/index.html', uri.path); |
| 83 Expect.equals(path, uri.toString()); |
| 84 |
| 60 path = 'http://[::FFFF:129.144.52.38]:80/index.html'; | 85 path = 'http://[::FFFF:129.144.52.38]:80/index.html'; |
| 61 uri = Uri.parse(path); | 86 uri = Uri.parse(path); |
| 62 Expect.equals('http', uri.scheme); | 87 Expect.equals('http', uri.scheme); |
| 63 Expect.equals('::FFFF:129.144.52.38', uri.domain); | 88 Expect.equals('::FFFF:129.144.52.38', uri.host); |
| 64 Expect.equals(80, uri.port); | 89 Expect.equals(0, uri.port); |
| 65 Expect.equals('/index.html', uri.path); | 90 Expect.equals('/index.html', uri.path); |
| 66 Expect.equals(path, uri.toString()); | 91 Expect.equals('http://[::FFFF:129.144.52.38]/index.html', uri.toString()); |
| 92 |
| 93 path = 'https://[::FFFF:129.144.52.38]:443/index.html'; |
| 94 uri = Uri.parse(path); |
| 95 Expect.equals('https', uri.scheme); |
| 96 Expect.equals('::FFFF:129.144.52.38', uri.host); |
| 97 Expect.equals(0, uri.port); |
| 98 Expect.equals('/index.html', uri.path); |
| 99 Expect.equals('https://[::FFFF:129.144.52.38]/index.html', uri.toString()); |
| 67 | 100 |
| 68 path = 'http://[2010:836B:4179::836B:4179]'; | 101 path = 'http://[2010:836B:4179::836B:4179]'; |
| 69 uri = Uri.parse(path); | 102 uri = Uri.parse(path); |
| 70 Expect.equals('http', uri.scheme); | 103 Expect.equals('http', uri.scheme); |
| 71 Expect.equals('2010:836B:4179::836B:4179', uri.domain); | 104 Expect.equals('2010:836B:4179::836B:4179', uri.host); |
| 72 Expect.equals(0, uri.port); | 105 Expect.equals(0, uri.port); |
| 73 Expect.equals('', uri.path); | 106 Expect.equals('', uri.path); |
| 74 Expect.equals(path, uri.toString()); | 107 Expect.equals(path, uri.toString()); |
| 75 } | 108 } |
| 76 | 109 |
| 77 void main() { | 110 void main() { |
| 78 testValidIpv6Uri(); | 111 testValidIpv6Uri(); |
| 79 } | 112 } |
| 80 | 113 |
| OLD | NEW |