better-opn
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -10,2 +10,8 @@ # Changelog | ||
## [2.1.0] - 2020-10-18 | ||
### Added | ||
- Support reuse tab with same host (#13) @otakustay | ||
## [2.0.0] - 2020-04-06 | ||
@@ -12,0 +18,0 @@ |
@@ -41,2 +41,15 @@ "use strict"; | ||
}; | ||
}; | ||
var normalizeURLToMatch = target => { | ||
// We may encounter URL parse error but want to fallback to default behavior | ||
try { | ||
// Url module is deprecated on newer version of NodeJS, only use it when URL class is not supported (like Node 8) | ||
var URL = // eslint-disable-next-line node/prefer-global/url | ||
typeof global.URL === 'undefined' ? require('url').URL : global.URL; | ||
var url = new URL(target); | ||
return url.origin; | ||
} catch (_unused) { | ||
return target; | ||
} | ||
}; // Copy from | ||
@@ -65,3 +78,3 @@ // https://github.com/facebook/create-react-app/blob/master/packages/react-dev-utils/openBrowser.js#L64 | ||
execSync('ps cax | grep "' + chromiumBrowser + '"'); | ||
execSync("osascript ../openChrome.applescript \"".concat(encodeURI(url), "\" \"").concat(chromiumBrowser, "\""), { | ||
execSync("osascript ../openChrome.applescript \"".concat(encodeURI(process.env.OPEN_MATCH_HOST_ONLY === 'true' ? normalizeURLToMatch(url) : url), "\" \"").concat(chromiumBrowser, "\""), { | ||
cwd: __dirname, | ||
@@ -68,0 +81,0 @@ stdio: 'ignore' |
{ | ||
"name": "better-opn", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "A better opn. Reuse the same tab on Chrome for 👨💻.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -22,4 +22,14 @@ # better-opn | ||
### Reuse tab by match host | ||
In case your app can navigate to another pathnames and still want to reuse opened tab, set environment variable `OPEN_MATCH_HOST_ONLY=true` can tell this program to find reusable tab by only match the host part of your URL. | ||
```js | ||
process.env.OPEN_MATCH_HOST_ONLY = 'true'; | ||
opn('http://localhost:3000/foo/bar'); // This will reuse any tab with URL starting with http://localhost:3000/ | ||
``` | ||
## Author | ||
- [Michael Lin](https://michaellin.me) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
250765
107
35
4