Skip to content

Commit

Permalink
fix: handle fallback for host only matching (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellzc authored Oct 20, 2020
1 parent 5821556 commit 37065aa
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions openChrome.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions test/host-only.js
Original file line number Diff line number Diff line change
@@ -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');
2 changes: 1 addition & 1 deletion test/open.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const opn = require('../dist/index');
const opn = require('../src/index');

opn('http://localhost:8000');

0 comments on commit 37065aa

Please sign in to comment.