mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 22:42:18 +00:00
Fixed non-expanding of URLs on open
This commit is contained in:
@@ -645,22 +645,26 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
|||||||
|
|
||||||
- (void)openURL:(id)sender {
|
- (void)openURL:(id)sender {
|
||||||
KPKEntry *selectedEntry = [[self currentTargetNode] asEntry];
|
KPKEntry *selectedEntry = [[self currentTargetNode] asEntry];
|
||||||
if(selectedEntry && [selectedEntry.url length] > 0) {
|
NSString *expandedURL = [selectedEntry.url finalValueForEntry:selectedEntry];
|
||||||
NSURL *webURL = [NSURL URLWithString:[selectedEntry.url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
if(expandedURL.length > 0) {
|
||||||
|
NSURL *webURL = [NSURL URLWithString:[expandedURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||||
NSString *scheme = [webURL scheme];
|
NSString *scheme = [webURL scheme];
|
||||||
if(!scheme) {
|
if(!scheme) {
|
||||||
webURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@", [selectedEntry.url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
|
webURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@", [expandedURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *browserBundleID = [[NSUserDefaults standardUserDefaults] objectForKey:kMPSettingsKeyBrowserBundleId];
|
NSString *browserBundleID = [[NSUserDefaults standardUserDefaults] objectForKey:kMPSettingsKeyBrowserBundleId];
|
||||||
BOOL launched = NO;
|
BOOL openedURL = NO;
|
||||||
|
|
||||||
if (browserBundleID) {
|
if(browserBundleID) {
|
||||||
launched = [[NSWorkspace sharedWorkspace] openURLs:@[webURL] withAppBundleIdentifier:browserBundleID options:NSWorkspaceLaunchAsync additionalEventParamDescriptor:nil launchIdentifiers:NULL];
|
openedURL = [[NSWorkspace sharedWorkspace] openURLs:@[webURL] withAppBundleIdentifier:browserBundleID options:NSWorkspaceLaunchAsync additionalEventParamDescriptor:nil launchIdentifiers:NULL];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!launched) {
|
if(!openedURL) {
|
||||||
[[NSWorkspace sharedWorkspace] openURL:webURL];
|
openedURL = [[NSWorkspace sharedWorkspace] openURL:webURL];
|
||||||
|
}
|
||||||
|
if(!openedURL) {
|
||||||
|
NSLog(@"Unable to open URL %@", webURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user