@guanzhu.me/pw-cli 0.0.3 → 0.0.4
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.
- package/bin/pw-cli.js +3 -2
- package/package.json +1 -1
package/bin/pw-cli.js
CHANGED
|
@@ -764,7 +764,8 @@ async function main() {
|
|
|
764
764
|
// - If a session is already running: open a new tab directly via our CDP executor
|
|
765
765
|
// - Otherwise: spawn open (no URL) to start the browser, then navigate via playwright-cli run-code
|
|
766
766
|
// (lenient wait strategy so redirects/login flows/SPA routing never time out)
|
|
767
|
-
const
|
|
767
|
+
const rawUrlArg = afterOpen.find(a => !a.startsWith('-') && /^(https?:\/\/|[a-zA-Z0-9]([a-zA-Z0-9-]*\.)+[a-zA-Z]{2,})/.test(a));
|
|
768
|
+
const urlArg = rawUrlArg && !/^https?:\/\//.test(rawUrlArg) ? `https://${rawUrlArg}` : rawUrlArg;
|
|
768
769
|
if (urlArg) {
|
|
769
770
|
const navCode = `async page => { const newPage = await page.context().newPage(); await newPage.goto(${JSON.stringify(urlArg)}, { waitUntil: 'domcontentloaded', timeout: 0 }); return newPage.url(); }`;
|
|
770
771
|
const alive = await isSessionAlive(session);
|
|
@@ -774,7 +775,7 @@ async function main() {
|
|
|
774
775
|
return;
|
|
775
776
|
}
|
|
776
777
|
const { spawnSync } = require('child_process');
|
|
777
|
-
const openOnlyArgs = injectOpenDefaults(afterOpen.filter(a => a !==
|
|
778
|
+
const openOnlyArgs = injectOpenDefaults(afterOpen.filter(a => a !== rawUrlArg));
|
|
778
779
|
const res = spawnSync(process.execPath, [cliPath, 'open', ...openOnlyArgs], {
|
|
779
780
|
stdio: 'inherit',
|
|
780
781
|
cwd: PW_CLI_DIR,
|
package/package.json
CHANGED