Skip to content

Commit

Permalink
fix: callback not trigger bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hejianxian committed Dec 13, 2019
1 parent a25b478 commit 8d4d8d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import protocolDetection from 'custom-protocol-detection';
import invariant from 'invariant';
import { stringify } from '@w6s/query-string';
import isString from 'lodash.isstring';
import isFunction from 'lodash.isstring';
import isFunction from 'lodash.isfunction';
import isObject from 'lodash.isobject';

/**
Expand All @@ -22,14 +22,15 @@ import isObject from 'lodash.isobject';
*/
function openDesktopApplication(params) {
try {
const { protocol, action, query, fail, success } = params;
const { target, protocol, action, query, fail, success } = params;
invariant(isString(protocol), '[protocol] Must be a non-empty string');
invariant(isString(action), '[action] Must be a non-empty string');

let openUri = `${protocol}://${action}`;
if (isObject(query)) {
openUri += `?${stringify(query)}`;
}

protocolDetection(
openUri,
function failCb(e) {
Expand All @@ -43,6 +44,7 @@ function openDesktopApplication(params) {
}
);
} catch (error) {
isFunction(fail) && fail(error);
console.log(error);
}
}
Expand Down

0 comments on commit 8d4d8d8

Please sign in to comment.