Skip to content

fix: do not stack a second scheme onto an http url - #606

Open
tju-yxq wants to merge 1 commit into
oss-compass:mainfrom
tju-yxq:fix/fill-https-double-scheme
Open

tju-yxq wants to merge 1 commit into
oss-compass:mainfrom
tju-yxq:fix/fill-https-double-scheme

Conversation

@tju-yxq

@tju-yxq tju-yxq commented Oct 20, 2026

Copy link
Copy Markdown

Motivation

if (trimmedUrl.indexOf('https') === -1) {
  return `https://${trimmedUrl}`;
}

indexOf('https') asks whether the string contains "https" anywhere, not whether it starts with
the scheme. A repository URL that already uses plain http therefore looked like it had no scheme
and came back with two of them:

"http://github.com/cli/cli" -> "https://http://github.com/cli/cli"

Change

Prepend https:// only when there is no scheme at all; an existing http:// or https:// prefix is
kept as-is. Trailing-slash trimming is unchanged.

Verification

New url.test.ts covers both branches:

# tests only
Tests:       1 failed, 1 passed, 2 total

# with the fix
Tests:       2 passed, 2 total

`fillHttps` checked `indexOf('https') === -1`, so a value that already started
with `http://` looked like it had no scheme at all and became
`https://http://github.com/...`.

Only prepend `https://` when the value has no scheme at all, keeping an existing
http or https prefix untouched.

Tests cover both branches: `url.test.ts` fails with the old implementation and
passes with this one.

Signed-off-by: Yxq <yu2651701064@tju.edu.cn>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 08:39
@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

@tju-yxq is attempting to deploy a commit to the codersett's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants