Skip to content

If protocol is not known then show unknown#296

Merged
spring1843 merged 1 commit into
mainfrom
unspecified-protocol
May 24, 2026
Merged

If protocol is not known then show unknown#296
spring1843 merged 1 commit into
mainfrom
unspecified-protocol

Conversation

@spring1843

Copy link
Copy Markdown
Owner

Summary

Fixes #285

When a user enters a bare hostname (e.g. example.com) into the URL to JSON
tool without specifying a protocol, the parser was internally prepending
https:// to satisfy the URL API and then returning protocol: "https" in
the output — a value the user never typed.

Changes

  • client/src/lib/url-parser.ts: Before the https:// prepend, capture
    whether the user's input contained a known protocol via KNOWN_PROTOCOLS_REGEX.
    If not, return protocol: "unknown" instead of the auto-prepended value. All
    other fields (hostname, domain, tld, etc.) continue to resolve correctly
    via the internal prepend.

  • tests/lib/url-parser.test.ts: Updated the existing
    "adds https:// when protocol is missing" test to assert "unknown" and
    renamed it to reflect correct behaviour. Added a companion test verifying that
    hostname, domain, and tld still parse correctly when no protocol is given.

  • tests/e2e/tools/url-to-json.spec.ts: New end-to-end test — inputs
    example.com, asserts protocol === "unknown" and hostname === "example.com".

Copilot AI review requested due to automatic review settings May 24, 2026 03:40
@netlify

netlify Bot commented May 24, 2026

Copy link
Copy Markdown

Deploy Preview for freedevtool ready!

Name Link
🔨 Latest commit 60db62a
🔍 Latest deploy log https://app.netlify.com/projects/freedevtool/deploys/6a127348d62b0b00082f925a
😎 Deploy Preview https://deploy-preview-296--freedevtool.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the URL parsing logic used by the URL-to-JSON tool so that when a user enters a URL/hostname without a recognized protocol (e.g. example.com), the output reports protocol: "unknown" instead of the internally prepended https.

Changes:

  • Track whether the user input included a protocol matched by KNOWN_PROTOCOLS_REGEX, and emit "unknown" when it did not.
  • Update unit tests to assert "unknown" for missing protocol and add coverage for hostname/domain/tld parsing in that case.
  • Add an E2E test ensuring the UI output shows "unknown" protocol for bare hostnames.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
client/src/lib/url-parser.ts Sets protocol to "unknown" when the input lacks a known protocol (while still parsing via an internal https:// prepend).
tests/lib/url-parser.test.ts Adjusts/extends unit tests for missing-protocol behavior and hostname/domain/tld parsing.
tests/e2e/tools/url-to-json.spec.ts Adds an end-to-end regression test for "unknown" protocol when input has no protocol.

Comment on lines +35 to 38
const userProvidedProtocol = KNOWN_PROTOCOLS_REGEX.test(urlToParse);
if (!userProvidedProtocol) {
urlToParse = `https://${urlToParse}`;
}
@spring1843 spring1843 merged commit 24ee5d0 into main May 24, 2026
6 checks passed
@spring1843 spring1843 deleted the unspecified-protocol branch May 24, 2026 03:59
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.

[Bug]: User has not entered any protocol but the website keep displaying the protocol as https

2 participants