Overview
Comment: | Move a few URL methods from OFString to OFURL |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f19cde3a14c295f7e1e930f68e61a359 |
User & Date: | js on 2019-02-03 19:19:52 |
Other Links: | manifest | tags |
Context
2019-02-07
| ||
00:46 | Make style consistent between ObjFW and ObjFW_RT check-in: ef6d69931e user: js tags: trunk | |
2019-02-03
| ||
19:19 | Move a few URL methods from OFString to OFURL check-in: f19cde3a14 user: js tags: trunk | |
17:52 | OFURL: Do not normalize in init with relative URL check-in: 2b13f285c5 user: js tags: trunk | |
Changes
Modified src/OFConstantString.m from [6574951a62] to [e40123b4c3].
︙ | |||
431 432 433 434 435 436 437 | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | - - - - - - - | - (OFString *)stringByAppendingPathComponent: (OFString *)component { [self finishInitialization]; return [self stringByAppendingPathComponent: component]; } |
︙ |
Modified src/OFString.h from [83d6b83c23] to [054ec39bed].
︙ | |||
211 212 213 214 215 216 217 | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | - - - - - - - - | * @brief The double value of the string as a double. * * If the string contains any non-number characters, an * OFInvalidEncodingException is thrown. */ @property (readonly, nonatomic) double doubleValue; |
︙ | |||
1037 1038 1039 1040 1041 1042 1043 | 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 | - - - - - - - - | * @param format A format string which generates the string to append * @param arguments The arguments used in the format string * @return A new, autoreleased OFString with the specified format appended */ - (OFString *)stringByAppendingFormat: (OFConstantString *)format arguments: (va_list)arguments; |
︙ |
Modified src/OFString.m from [ac5117fe19] to [b076cd8540].
︙ | |||
2038 2039 2040 2041 2042 2043 2044 | 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 | - - - - - - - - - - - - - - - - | arguments: arguments]; [new makeImmutable]; return new; } |
︙ | |||
2327 2328 2329 2330 2331 2332 2333 | 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | [array makeImmutable]; objc_autoreleasePoolPop(pool); return array; } |
︙ |
Modified src/OFURL.h from [e32aace5ab] to [b537389466].
︙ | |||
138 139 140 141 142 143 144 145 146 147 148 149 150 151 | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | + + + + + | OFString *URLEncodedFragment; /*! * @brief The URL as a string. */ @property (readonly, nonatomic) OFString *string; /*! * @brief The URL with relative sub paths resolved. */ @property (readonly, nonatomic) OFURL *URLByStandardizingPath; #ifdef OF_HAVE_FILES /*! * @brief The local file system representation for a file URL. * * @note This only exists for URLs with the file scheme and throws an exception * otherwise. * |
︙ |
Modified src/OFURL.m from [684f4e251d] to [4bf97fa647].
︙ | |||
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 | 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | objc_autoreleasePoolPop(pool); } [ret makeImmutable]; return ret; } - (OFURL *)URLByStandardizingPath { void *pool; OFMutableArray OF_GENERIC(OFString *) *array; bool done = false, endsWithEmpty; OFString *path; OFMutableURL *URL; if (_URLEncodedPath == nil) return self; pool = objc_autoreleasePoolPush(); array = [[[_URLEncodedPath componentsSeparatedByString: @"/"] mutableCopy] autorelease]; if ([[array firstObject] length] != 0) @throw [OFInvalidFormatException exception]; endsWithEmpty = ([[array lastObject] length] == 0); while (!done) { size_t length = [array count]; done = true; for (size_t i = 0; i < length; i++) { id object = [array objectAtIndex: i]; id parent = (i > 0 ? [array objectAtIndex: i - 1] : nil); if ([object isEqual: @"."] || [object length] == 0) { [array removeObjectAtIndex: i]; done = false; break; } if ([object isEqual: @".."] && parent != nil && ![parent isEqual: @".."]) { [array removeObjectsInRange: of_range(i - 1, 2)]; done = false; break; } } } [array insertObject: @"" atIndex: 0]; if (endsWithEmpty) [array addObject: @""]; path = [array componentsJoinedByString: @"/"]; if ([path length] == 0) path = @"/"; URL = [[self mutableCopy] autorelease]; [URL setURLEncodedPath: path]; [URL makeImmutable]; [URL retain]; objc_autoreleasePoolPop(pool); return [URL autorelease]; } - (OFString *)description { return [OFString stringWithFormat: @"<%@: %@>", [self class], [self string]]; } |
︙ |
Modified tests/OFStringTests.m from [ec27cf1f39] to [f95cef297c].
︙ | |||
587 588 589 590 591 592 593 | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | - - - - - - - - - - - | is = [stringClass stringWithString: s[1]]; [s[1] appendString: @"baz"]; TEST(@"-[stringByAppendingPathComponent:]", [[s[0] stringByAppendingPathComponent: @"baz"] isEqual: s[1]] && [[is stringByAppendingPathComponent: @"baz"] isEqual: s[1]]) #endif |
︙ |
Modified tests/OFURLTests.m from [2aa332308d] to [65b67dad50].
︙ | |||
272 273 274 275 276 277 278 279 280 281 | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | + + + + + + + + + + + + + + | isDirectory: false] isEqual: [OFURL URLWithString: @"file:///qu%3Fx"]] && [[[OFURL URLWithString: @"file:///foo/bar/"] URLByAppendingPathComponent: @"/qu?x" isDirectory: true] isEqual: [OFURL URLWithString: @"file:///qu%3Fx/"]]) TEST(@"-[URLByStandardizingPath]", [[[OFURL URLWithString: @"http://foo/bar/.."] URLByStandardizingPath] isEqual: [OFURL URLWithString: @"http://foo/"]] && [[[OFURL URLWithString: @"http://foo/bar/%2E%2E/../qux/"] URLByStandardizingPath] isEqual: [OFURL URLWithString: @"http://foo/bar/qux/"]] && [[[OFURL URLWithString: @"http://foo/bar/./././qux/./"] URLByStandardizingPath] isEqual: [OFURL URLWithString: @"http://foo/bar/qux/"]] && [[[OFURL URLWithString: @"http://foo/bar/../../qux"] URLByStandardizingPath] isEqual: [OFURL URLWithString: @"http://foo/../qux"]]) [pool drain]; } @end |