diff --git a/openChrome.applescript b/openChrome.applescript index b7b0161..8aaa419 100644 --- a/openChrome.applescript +++ b/openChrome.applescript @@ -11,11 +11,12 @@ property theProgram: "Google Chrome" on run argv set theURL to item 1 of argv + set matchURL to item 2 of argv -- Allow requested program to be optional, -- default to Google Chrome - if (count of argv) > 1 then - set theProgram to item 2 of argv + if (count of argv) > 2 then + set theProgram to item 3 of argv end if using terms from application "Google Chrome" @@ -28,7 +29,7 @@ on run argv -- 1: Looking for tab running debugger -- then, Reload debugging tab if found -- then return - set found to my lookupTabWithUrl(theURL) + set found to my lookupTabWithUrl(matchURL) if found then set targetWindow's active tab index to targetTabIndex tell targetTab to reload diff --git a/src/index.js b/src/index.js index 575d178..1c8138b 100644 --- a/src/index.js +++ b/src/index.js @@ -70,11 +70,11 @@ const startBrowserProcess = (browser, url, opts = {}, args = []) => { // on OSX Chromium-based browser with AppleScript execSync('ps cax | grep "' + chromiumBrowser + '"'); execSync( - `osascript ../openChrome.applescript "${encodeURI( + `osascript ../openChrome.applescript "${encodeURI(url)}" ${ process.env.OPEN_MATCH_HOST_ONLY === 'true' - ? normalizeURLToMatch(url) - : url - )}" "${chromiumBrowser}"`, + ? encodeURI(normalizeURLToMatch(url)) + : encodeURI(url) + } "${chromiumBrowser}"`, { cwd: __dirname, stdio: 'ignore', diff --git a/test/host-only.js b/test/host-only.js index 894722f..69a7967 100644 --- a/test/host-only.js +++ b/test/host-only.js @@ -1,5 +1,5 @@ -const opn = require('../dist/index'); +const opn = require('../src/index'); // Run test/open.js first, then run this to ensure tab is reused process.env.OPEN_MATCH_HOST_ONLY = 'true'; -opn('http://localhost:8000/foo/bar'); +opn('http://localhost:8000/foo'); diff --git a/test/open.js b/test/open.js index 9601ab7..3c07b89 100644 --- a/test/open.js +++ b/test/open.js @@ -1,3 +1,3 @@ -const opn = require('../dist/index'); +const opn = require('../src/index'); opn('http://localhost:8000');