Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle fallback for host only matching #15

Merged
merged 1 commit into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');