blob: 11b84ed8fae992b7d7adf86918f221d33a13b766 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#import "NSURL+MGLAdditions.h"
@implementation NSURL (MGLAdditions)
- (nullable NSURL *)mgl_URLByStandardizingScheme {
if (!self.scheme) {
// Relative file URL, already escaped (in order to create the NSURL).
// Assume a relative path into the application’s resource folder.
return [NSURL URLWithString:[@"asset://" stringByAppendingString:self.absoluteString]];
} else if (self.fileURL) {
// Absolute file URL, so construct a new URL using the unescaped path.
NSURLComponents *components = [[NSURLComponents alloc] init];
components.scheme = @"asset";
components.host = @"";
components.path = self.path;
return components.URL;
}
return self;
}
@end
|