Differences From Artifact [963a0a611c]:
- File src/OFMutableURI.m — part of check-in [e7ab06503c] at 2022-09-28 21:40:00 on branch trunk — Rename OFUR{L -> I} in preparation for URI support (user: js, size: 10663) [annotate] [blame] [check-ins using]
To Artifact [a21b779d5d]:
- File
src/OFMutableURI.m
— part of check-in
[bd6dd6dd00]
at
2022-09-29 21:53:01
on branch trunk
— OFURI: Make query items an array of pairs
With a dictionary the order is lost and keys cannot exist more than
once. (user: js, size: 10520) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #import "OFMutableURI.h" #import "OFArray.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFileManager.h" #endif #import "OFNumber.h" #import "OFString.h" #import "OFInvalidFormatException.h" @implementation OFMutableURI @dynamic scheme, percentEncodedScheme, host, percentEncodedHost, port, user; @dynamic percentEncodedUser, password, percentEncodedPassword, path; @dynamic percentEncodedPath, pathComponents, query, percentEncodedQuery; | > | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #import "OFMutableURI.h" #import "OFArray.h" #import "OFDictionary.h" #ifdef OF_HAVE_FILES # import "OFFileManager.h" #endif #import "OFNumber.h" #import "OFPair.h" #import "OFString.h" #import "OFInvalidFormatException.h" @implementation OFMutableURI @dynamic scheme, percentEncodedScheme, host, percentEncodedHost, port, user; @dynamic percentEncodedUser, password, percentEncodedPassword, path; @dynamic percentEncodedPath, pathComponents, query, percentEncodedQuery; @dynamic queryItems, fragment, percentEncodedFragment; + (instancetype)URI { return [[[self alloc] init] autorelease]; } - (void)setScheme: (OFString *)scheme |
︙ | ︙ | |||
231 232 233 234 235 236 237 | [OFCharacterSet URIQueryAllowedCharacterSet]); old = _percentEncodedQuery; _percentEncodedQuery = [percentEncodedQuery copy]; [old release]; } | | | > < | | < < > | < | | | | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | [OFCharacterSet URIQueryAllowedCharacterSet]); old = _percentEncodedQuery; _percentEncodedQuery = [percentEncodedQuery copy]; [old release]; } - (void)setQueryItems: (OFArray OF_GENERIC(OFPair OF_GENERIC(OFString *, OFString *) *) *) queryItems { void *pool; OFMutableString *percentEncodedQuery; OFCharacterSet *characterSet; OFString *old; if (queryItems == nil) { [_percentEncodedQuery release]; _percentEncodedQuery = nil; return; } pool = objc_autoreleasePoolPush(); percentEncodedQuery = [OFMutableString string]; characterSet = [OFCharacterSet URIQueryKeyValueAllowedCharacterSet]; for (OFPair OF_GENERIC(OFString *, OFString *) *item in queryItems) { OFString *key = [item.firstObject stringByAddingPercentEncodingWithAllowedCharacters: characterSet]; OFString *value = [item.secondObject stringByAddingPercentEncodingWithAllowedCharacters: characterSet]; if (percentEncodedQuery.length > 0) [percentEncodedQuery appendString: @"&"]; [percentEncodedQuery appendFormat: @"%@=%@", key, value]; } old = _percentEncodedQuery; _percentEncodedQuery = [percentEncodedQuery copy]; [old release]; objc_autoreleasePoolPop(pool); |
︙ | ︙ |