• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Links with ../ and /
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Links with ../ and /


  • Subject: Links with ../ and /
  • From: "Mr. Gecko" <email@hidden>
  • Date: Wed, 19 Nov 2008 23:13:29 -0600

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:@"%@%@", [linkArray objectAtIndex:l], ([linkArray count]==l+2 ? @"" : @"/")];
}
}
link = [NSString stringWithFormat:@"%@%@%@", ([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@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Links with ../ and /
      • From: Ken Thomases <email@hidden>
    • Re: Links with ../ and /
      • From: Rob Keniger <email@hidden>
  • Prev by Date: Using properties (was Re: Outlets / IBOutlet declarations)
  • Next by Date: Wrapping C functions in Objective C proxy objects: naming convention?
  • Previous by thread: Re: Setter Declaration for Scalar, with @property --> Silent Runtime Failure
  • Next by thread: Re: Links with ../ and /
  • Index(es):
    • Date
    • Thread