-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathXXXApolloOpener.m
38 lines (27 loc) · 984 Bytes
/
XXXApolloOpener.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#import <Opener/Opener.h>
@interface XXXApolloOpener : HBLOHandler
@end
@implementation XXXApolloOpener
- (instancetype)init {
self = [super init];
if (self) {
self.name = @"Apollo Opener";
self.identifier = @"com.gilshahar7.apolloopener";
}
return self;
}
- (id)openURL:(NSURL *)url sender:(NSString *)sender {
if ([url.host isEqualToString:@"www.reddit.com"] ||
[url.host isEqualToString:@"reddit.com"] ||
[url.host isEqualToString:@"m.reddit.com"] ||
[url.host isEqualToString:@"old.reddit.com"] ||
[url.host containsString:@".reddit.com"]) {
if ([url.path isEqualToString:@"/"] || [url.path isEqualToString:@""]) {
return [NSURL URLWithString:@"apollo://"];
} else {
return [NSURL URLWithString:[NSString stringWithFormat:@"apollo://reddit.com%@/?%@", url.path, url.query]];
}
}
return nil;
}
@end