@@ -190,9 +190,22 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification;
190
190
if (defaults[@" activate" ]) options[@" bundleID" ] = defaults[@" activate" ];
191
191
if (defaults[@" group" ]) options[@" groupID" ] = defaults[@" group" ];
192
192
if (defaults[@" execute" ]) options[@" command" ] = defaults[@" execute" ];
193
- if (defaults[@" open" ]) options[@" open" ] = [defaults[@" open" ] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
194
193
if (defaults[@" appIcon" ]) options[@" appIcon" ] = defaults[@" appIcon" ];
195
194
if (defaults[@" contentImage" ]) options[@" contentImage" ] = defaults[@" contentImage" ];
195
+ if (defaults[@" open" ]) {
196
+ /*
197
+ * it may be better to use stringByAddingPercentEncodingWithAllowedCharacters instead of stringByAddingPercentEscapesUsingEncoding,
198
+ * but stringByAddingPercentEncodingWithAllowedCharacters is only available on OS X 10.9 or higher.
199
+ */
200
+ NSString *encodedURL = [defaults[@" open" ] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
201
+ NSURL *url = [NSURL URLWithString: defaults[@" open" ]];
202
+ NSString *fragment = [url fragment ];
203
+ if (fragment) {
204
+ options[@" open" ] = [self decodeFragmentInURL: encodedURL fragment: fragment];
205
+ } else {
206
+ options[@" open" ] = encodedURL;
207
+ }
208
+ }
196
209
197
210
[self deliverNotificationWithTitle: defaults[@" title" ] ?: @" Terminal"
198
211
subtitle: subtitle
@@ -213,6 +226,20 @@ - (NSImage*)getImageFromURL:(NSString *) url;
213
226
return [[NSImage alloc ] initWithContentsOfURL: imageURL];
214
227
}
215
228
229
+ /* *
230
+ * Decode fragment identifier
231
+ *
232
+ * @see http://tools.ietf.org/html/rfc3986#section-2.1
233
+ * @see http://en.wikipedia.org/wiki/URI_scheme
234
+ */
235
+ - (NSString *)decodeFragmentInURL : (NSString *) encodedURL fragment : (NSString *) framgent
236
+ {
237
+ NSString *beforeStr = [@" %23" stringByAppendingString: framgent];
238
+ NSString *afterStr = [@" #" stringByAppendingString: framgent];
239
+ NSString *decodedURL = [encodedURL stringByReplacingOccurrencesOfString: beforeStr withString: afterStr];
240
+ return decodedURL;
241
+ }
242
+
216
243
- (void )deliverNotificationWithTitle : (NSString *)title
217
244
subtitle : (NSString *)subtitle
218
245
message : (NSString *)message
0 commit comments