@ai-ecoverse/sliccy-browser 0.1.35 → 0.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/browser.js +9 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/sliccy-browser",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "sliccy:browser for jsh, over CDP",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/src/browser.js CHANGED
@@ -304,12 +304,15 @@ async function findTabNow(query = {}) {
304
304
  throw new Error('browser.findTab: query requires `domain` or `urlMatch`');
305
305
  }
306
306
  const tabs = await listTabs();
307
- if (domain !== undefined) {
308
- const wanted = domain.toLowerCase();
309
- return tabs.find((tab) => hostnameOf(tab.url)?.toLowerCase() === wanted) ?? null;
310
- }
311
- const re = compilePattern(urlMatch, 'browser.findTab');
312
- return tabs.find((tab) => re.test(tab.url)) ?? null;
307
+ const wanted = domain?.toLowerCase();
308
+ const re = urlMatch === undefined ? undefined : compilePattern(urlMatch, 'browser.findTab');
309
+ return (
310
+ tabs.find(
311
+ (tab) =>
312
+ (wanted === undefined || hostnameOf(tab.url)?.toLowerCase() === wanted) &&
313
+ (re === undefined || re.test(tab.url))
314
+ ) ?? null
315
+ );
313
316
  }
314
317
 
315
318
  export async function ensureTab(url, options) {