Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Add NSURL URLByAppendingFragment extension
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisreimann committed Jun 13, 2013
1 parent 5b6eb4e commit 1a5299b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions Classes/Extensions/NSURL+Extensions.h
Expand Up @@ -8,6 +8,7 @@
- (NSURL *)URLByAppendingParams:(NSDictionary *)params;
- (NSURL *)URLByAppendingTrailingSlash;
- (NSURL *)URLByDeletingTrailingSlash;
- (NSURL *)URLByAppendingFragment:(NSString *)string;
- (NSDictionary *)queryDictionary;
- (BOOL)hasTrailingSlash;
- (BOOL)isGitHubURL;
Expand Down
9 changes: 9 additions & 0 deletions Classes/Extensions/NSURL+Extensions.m
Expand Up @@ -104,6 +104,15 @@ - (NSDictionary *)queryDictionary {
return dict;
}

- (NSURL *)URLByAppendingFragment:(NSString *)fragment {
NSString *oldFragment = self.fragment;
NSString *absoluteString = self.absoluteString;
if (oldFragment) [absoluteString substringWithRange:NSMakeRange(0, absoluteString.length - oldFragment.length + 1)];
absoluteString = [absoluteString stringByAppendingString:@"#"];
absoluteString = [absoluteString stringByAppendingString:fragment];
return [NSURL URLWithString:absoluteString];
}

// Checks the host to see whether or not this is a GitHub URL.
// Assumes that relative links are also GitHubcom URLs.
- (BOOL)isGitHubURL {
Expand Down

0 comments on commit 1a5299b

Please sign in to comment.