Differences From Artifact [96f3992920]:
- File
tests/OFURLTests.m
— part of check-in
[5f7305c659]
at
2017-10-31 21:39:36
on branch trunk
— OFURL: URL-encode according to RFC 3986
This also means the parameters go away and get folded into the path. (user: js, size: 4118) [annotate] [blame] [check-ins using]
To Artifact [291a443212]:
- File
tests/OFURLTests.m
— part of check-in
[a15b403a11]
at
2017-11-06 23:01:57
on branch trunk
— OFURL: Store the URL-encoded version internally
This allows retrieving it how it was originally stored, which is useful
for example for query strings, as these often URL-encode allowed
characters in order to allow pairs of the form foo=bar&bar=qux. (user: js, size: 4962) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
26 27 28 29 30 31 32 | #import "OFAutoreleasePool.h" #import "OFInvalidFormatException.h" #import "TestsAppDelegate.h" static OFString *module = @"OFURL"; | | > | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #import "OFAutoreleasePool.h" #import "OFInvalidFormatException.h" #import "TestsAppDelegate.h" static OFString *module = @"OFURL"; static OFString *url_str = @"ht%3atp://us%3Aer:p%40w@ho%3Ast:1234/" @"pa%3Fth?que%23ry#frag%23ment"; @implementation TestsAppDelegate (OFURLTests) - (void)URLTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFURL *u1, *u2, *u3, *u4; OFMutableURL *mu; TEST(@"+[URLWithString:]", R(u1 = [OFURL URLWithString: url_str]) && R(u2 = [OFURL URLWithString: @"http://foo:80"]) && R(u3 = [OFURL URLWithString: @"http://bar/"]) && R(u4 = [OFURL URLWithString: @"file:///etc/passwd"])) TEST(@"+[URLWithString:relativeToURL:]", [[[OFURL URLWithString: @"/foo" relativeToURL: u1] string] isEqual: @"ht%3atp://us%3Aer:p%40w@ho%3Ast:1234/foo"] && [[[OFURL URLWithString: @"foo/bar?q" relativeToURL: [OFURL URLWithString: @"http://h/qux/quux"]] string] isEqual: @"http://h/qux/foo/bar?q"] && [[[OFURL URLWithString: @"foo/bar" relativeToURL: [OFURL URLWithString: @"http://h/qux/?x"]] string] isEqual: @"http://h/qux/foo/bar"] && [[[OFURL URLWithString: @"http://foo/?q" |
︙ | ︙ | |||
107 108 109 110 111 112 113 114 115 116 | [[OFURL URLWithString: @"HTTP://bar/"] isEqual: u3]) TEST(@"-[hash:]", [u1 hash] == [u4 hash] && [u2 hash] != [u3 hash]) EXPECT_EXCEPTION(@"Detection of invalid format", OFInvalidFormatException, [OFURL URLWithString: @"http"]) [pool drain]; } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | [[OFURL URLWithString: @"HTTP://bar/"] isEqual: u3]) TEST(@"-[hash:]", [u1 hash] == [u4 hash] && [u2 hash] != [u3 hash]) EXPECT_EXCEPTION(@"Detection of invalid format", OFInvalidFormatException, [OFURL URLWithString: @"http"]) mu = [OFMutableURL URL]; TEST(@"-[setScheme:]", R([mu setScheme: @"ht:tp"]) && [[mu URLEncodedScheme] isEqual: @"ht%3Atp"]) TEST(@"-[setHost:]", R([mu setHost: @"ho:st"]) && [[mu URLEncodedHost] isEqual: @"ho%3Ast"]) TEST(@"-[setUser:]", R([mu setUser: @"us:er"]) && [[mu URLEncodedUser] isEqual: @"us%3Aer"]) TEST(@"-[setPassword:]", R([mu setPassword: @"pass:word"]) && [[mu URLEncodedPassword] isEqual: @"pass%3Aword"]) TEST(@"-[setPath:]", R([mu setPath: @"pa/th@?"]) && [[mu URLEncodedPath] isEqual: @"pa/th@%3F"]) TEST(@"-[setQuery:]", R([mu setQuery: @"que/ry?#"]) && [[mu URLEncodedQuery] isEqual: @"que/ry?%23"]) TEST(@"-[setFragment:]", R([mu setFragment: @"frag/ment?#"]) && [[mu URLEncodedFragment] isEqual: @"frag/ment?%23"]) [pool drain]; } @end |