8000 fix(targets): read a capitalized scheme in the target host field by kevin9327 · Pull Request #4090 · fosrl/pangolin · GitHub
[go: up one dir, main page]

Skip to content

fix(targets): read a capitalized scheme in the target host field - #4090

Open
kevin9327 wants to merge 1 commit into
fosrl:devfrom
kevin9327:fix-uppercase-target-scheme
Open

kevin9327 wants to merge 1 commit into
fosrl:devfrom
kevin9327:fix-uppercase-target-scheme

Conversation

@kevin9327
Copy link
Copy Markdown

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

AI Disclosure

This change was prepared with AI assistance: code, test and description. It was reviewed and tested before submission.

Description

The target host field splits a pasted scheme://host:port into method, host and port, but it only recognizes the scheme in lowercase. Typing Https://example.com:8443 (phone keyboards capitalize the first letter) skips the scheme check, so parseHostTarget prepends http:// and parses http://Https://example.com:8443. The URL parser then reads https as the hostname and finds no port, so the target is saved with host https and port 80.

URL schemes are case-insensitive, so this adds the i flag to the scheme pattern and shares it between parseHostTarget and the host field's hasProtocol check, so both agree. The protocol returned is already lowercase because it comes from URL.protocol.

How to test?

npx tsx src/lib/parseHostTarget.test.ts: the new test covers lowercase, scheme-less and capitalized (Https, HTTP, H2C) inputs. The capitalized cases fail on dev (host https, port 80) and pass with this change.

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.

1 participant

0