+ if (debugURLProcessing)
+ NSLog(@"%s: => '%@'", __PRETTY_FUNCTION__, result);
+ return result;
+}
+
+- (NSString *)urlPathRelativeToPath:(NSString *)_base {
+ /*
+ This can be used for URLs in the same namespace. It should
+ never return an absolute path (it only does in error conditions).
+ */
+ // TODO: the implementation can probably be optimized a _LOT_
+
+ if (_base == nil || [_base length] == 0) {
+ NSLog(@"%s: invalid base (nil or length 0), using absolute path '%@' ...",
+ __PRETTY_FUNCTION__, self);
+ return self;
+ }
+
+ if ([_base isEqualToString:@"/"])
+ return [self urlPathRelativeToRoot];
+ if ([_base isEqualToString:self])
+ return [self urlPathRelativeToSelf];
+
+ if (debugURLProcessing)
+ NSLog(@"%s: %@ relative to %@ ...", __PRETTY_FUNCTION__, self, _base);
+
+ if ([self hasPrefix:_base])
+ return calcRelativePathOfChildURL(self, _base);