Skip to content

feat(templated_uri): add try_effective_port method#451

Open
martintmk wants to merge 3 commits into
mainfrom
feat/templated-uri-try-effective-port
Open

feat(templated_uri): add try_effective_port method#451
martintmk wants to merge 3 commits into
mainfrom
feat/templated-uri-try-effective-port

Conversation

@martintmk
Copy link
Copy Markdown
Member

Adds a fallible variant of effective_port on Origin and BaseUri that returns a UriError when the authority does not specify a port and the scheme has no well-known default known to this crate (http, https).

(noticed that this could be useful when using the effective_port in our codebase)

Adds a fallible variant of effective_port on Origin and BaseUri that returns a UriError when the authority does not specify a port and the scheme has no well-known default known to this crate (http, https).
Copilot AI review requested due to automatic review settings May 26, 2026 14:22
Copy link
Copy Markdown
Contributor

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 adds a fallible “effective port” accessor to templated_uri so callers can get a Result<u16, UriError> instead of Option<u16> when the scheme has no default port known to the crate.

Changes:

  • Added Origin::try_effective_port() returning an error when the port can’t be inferred.
  • Added BaseUri::try_effective_port() delegating to Origin.
  • Added tests and doc examples for the new APIs.

Reviewed changes

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

File Description
crates/templated_uri/src/origin.rs Adds Origin::try_effective_port() and tests covering explicit ports, http/https defaults, and unknown-scheme error behavior.
crates/templated_uri/src/base_uri.rs Adds BaseUri::try_effective_port() and tests for success cases (explicit/http/https default).

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

Comment thread crates/templated_uri/src/base_uri.rs Outdated
Comment thread crates/templated_uri/src/base_uri.rs
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (ee55322) to head (ecf4f24).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #451   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files         305      305           
  Lines       23707    23741   +34     
=======================================
+ Hits        23707    23741   +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

@sgalkin sgalkin left a comment

Choose a reason for hiding this comment

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

Please address both Copilot comment - remove crate:: from UriError and add negative test case

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 28, 2026 14:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

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 2 out of 2 changed files in this pull request and generated no new comments.

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.

3 participants