"Normalize" a URL
"Normalize" a URL
- Subject: "Normalize" a URL
- From: Jerry Krinock <email@hidden>
- Date: Sat, 27 Jan 2007 20:44:02 -0800
- Thread-topic: "Normalize" a URL
I am looking for a method to "normalize" URLs (the way Google Bookmarks
does). By this, I mean that:
1) Last path component "/index.html" or "/index.htm" is changed to "/".
2) If no path, the path "/" is appended.
3) Any uppercase letters are converted to lowercase.
4) If two consecutive slashes in the path ("//"), one of them is removed.
5) An empty query, that is, a "?" at the end of a URL, is removed.
6) An empty identifier, that is a "#", at the end of a path, is removed.
7) Characters which are encoded as percent-escapes, but according to RFC
2396 should not be encoded, are decoded.
8) Characters which are not encoded as percent-escapes, but according to
RFC 2396 should be encoded, are encoded.
and possibly other things I haven't noticed.
I see from CFURLCreateStringByAddingPercentEscapes() documentation that 7)
and 8) can be done by following CFURLCreateStringByReplacingPercentEscapes()
with CFURLCreateStringByAddingPercentEscapes(). But does anyone know of any
code which will do all of those items 1) - 8)? It wouldn't be hard to do my
own implementation, but I may be missing something, so using a standard
implementation would be very nice!
Thanks,
Jerry Krinock
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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