Skip to content

Commit e128010

Browse files
author
Ufuk Kayserilioglu
committed
Only prepend file:// scheme if there is no scheme
'appIcon' and 'contentImage' options could actually accept data:, http(s):, etc URIs. However, the fact that the current version checks explicitly for file:// URIs cripples that use case. This commit tries to treat the given string as a URI. However, if the URI does not have a scheme, then 'file://' is appended and the resulting string is re-interpreted as the final URI. Otherwise, we are set anyway.
1 parent d3fe4a3 commit e128010

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Terminal Notifier/AppDelegate.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,11 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification;
205205

206206
- (NSImage*)getImageFromURL:(NSString *) url;
207207
{
208-
if(!contains(url, @"file://")){ // Prefix file:// if not present
208+
NSURL *imageURL = [NSURL URLWithString:url];
209+
if([[imageURL scheme] length] == 0){ // Prefix file:// if no scheme
209210
url = [NSString stringWithFormat:@"%@%@", @"file://", url];
211+
imageURL = [NSURL URLWithString:url];
210212
}
211-
NSURL *imageURL = [NSURL URLWithString:url];
212213
return [[NSImage alloc] initWithContentsOfURL:imageURL];
213214
}
214215

0 commit comments

Comments
 (0)