Skip to content

Support ports in URL to check#82

Merged
spaze merged 1 commit intomainfrom
spaze/url-ports
Apr 6, 2026
Merged

Support ports in URL to check#82
spaze merged 1 commit intomainfrom
spaze/url-ports

Conversation

@spaze
Copy link
Copy Markdown
Owner

@spaze spaze commented Apr 6, 2026

No description provided.

@spaze spaze self-assigned this Apr 6, 2026
Copilot AI review requested due to automatic review settings April 6, 2026 21:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates URL handling so that when a caller provides a URL containing a non-default port, the check/fetch logic preserves that port when constructing the /.well-known/security.txt and /security.txt fetch URLs.

Changes:

  • Extend URL parsing tests to assert port extraction and default-port normalization.
  • Update SecurityTxtFetcher::fetch() to build well-known/top-level URLs from the provided Url (preserving port) instead of reconstructing from host only.
  • Add a fetcher test ensuring constructed/final URLs include an explicitly specified port.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Parser/SecurityTxtUrlParser.php Rejects parsed URLs that have no host (prevents accepting inputs like example.com:4433 as a “scheme”).
src/Fetcher/SecurityTxtFetcher.php Constructs fetch URLs via withScheme/withPath to preserve port; adds InvalidUrlException to the declared throws.
src/Check/SecurityTxtCheckHost.php Updates doc comment to state that port is used.
tests/Parser/SecurityTxtUrlParserTest.phpt Adds port expectations to URL parsing cases and adds a “no scheme with port” bad-input case.
tests/Fetcher/SecurityTxtFetcherTest.phpt Adds coverage that fetch preserves a non-default port in constructed/final URLs.
Comments suppressed due to low confidence (1)

src/Check/SecurityTxtCheckHost.php:87

  • SecurityTxtCheckHost::check() calls SecurityTxtFetcher::fetch(), which is now annotated to throw Uri\WhatWg\InvalidUrlException, but check()'s docblock doesn't mention it and it isn't handled. Either handle/wrap it inside check()/fetch() or add the missing @throws to keep the public API documentation accurate.
	/**
	 * @param Url $url Only the host and port parts of the URL will be used
	 * @param non-negative-int|null $maxAllowedRedirects
	 * @throws SecurityTxtHostNotFoundException
	 * @throws SecurityTxtCannotParseHostnameException
	 * @throws SecurityTxtCannotOpenUrlExtensionNotLoadedException
	 * @throws SecurityTxtTooManyRedirectsException

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Parser/SecurityTxtUrlParserTest.phpt
Comment thread src/Fetcher/SecurityTxtFetcher.php Outdated
Comment thread src/Fetcher/SecurityTxtFetcher.php
Comment thread tests/Fetcher/SecurityTxtFetcherTest.phpt Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@spaze spaze merged commit 165de0c into main Apr 6, 2026
10 checks passed
@spaze spaze deleted the spaze/url-ports branch April 6, 2026 21:53
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