How do I handle links with ../ for previous directory and / for front
of url.
I am current;y doing it with
NSArray *linkArray = [[self replace:@"http://" with:@"" source:[self
replace:@"https://" with:@"" source:link]]
componentsSeparatedByString:@"/"];
if ([linkArray count]!=0) {
NSString *thisDomain = [linkArray objectAtIndex:0];
if (![link hasPrefix:@"http://"] && ![link hasPrefix:@"https://"]) {
NSString *newLink = @"";
thisDomain = [urlArray objectAtIndex:0];
for (l=0; l<[linkArray count]; l++) {
if ([[linkArray objectAtIndex:l]
isEqualToString:@".."]) {
newLink = [newLink stringByAppendingFormat:@"%@/", [urlArray
objectAtIndex:l+1]];
} else {
newLink = [newLink stringByAppendingFormat:@"[EMAIL PROTECTED]@", [linkArray
objectAtIndex:l], ([linkArray count]==l+2 ? @"" : @"/")];
}
}
link = [NSString stringWithFormat:@"[EMAIL PROTECTED]@%@", ([url
hasPrefix:@"http://"] ? @"http://" : @"https://"), [urlArray
objectAtIndex:0], ([newLink hasPrefix:@"/"] ? newLink : [NSString
stringWithFormat:@"/%@", newLink])];
}
}
This does have some problems though. if it is a file it would still
trail with a /.
thanks for helping me,
Mr. Gecko
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]