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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] Strip scheme from vc inspect argument #8307

Merged
merged 4 commits into from
Aug 3, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/cli/src/commands/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default async function main(client: Client) {
const { print, log, error } = client.output;

// extract the first parameter
const [, deploymentIdOrHost] = argv._;
let [, deploymentIdOrHost] = argv._;

if (argv._.length !== 2) {
error(`${getCommandName('inspect <url>')} expects exactly one argument`);
Expand All @@ -92,6 +92,7 @@ export default async function main(client: Client) {

// resolve the deployment, since we might have been given an alias
const depFetchStart = Date.now();
deploymentIdOrHost = stripScheme(deploymentIdOrHost);
client.output.spinner(
`Fetching deployment "${deploymentIdOrHost}" in ${chalk.bold(contextName)}`
);
Expand Down Expand Up @@ -212,3 +213,11 @@ function stateString(s: Deployment['readyState']) {
return chalk.gray('UNKNOWN');
}
}

function stripScheme(deploymentIdOrHost: string): string {
const match = deploymentIdOrHost.match(/http:\/\/|https:\/\//g)?.[0];
styfle marked this conversation as resolved.
Show resolved Hide resolved
if (match) {
deploymentIdOrHost = deploymentIdOrHost.replace(match, '');
}
return deploymentIdOrHost;
}