Skip to content

Invalidate URI caches after component changes - #613

Open
OskarEichler wants to merge 1 commit into
sporkmonger:mainfrom
OskarEichler:codex/addressable-cache
Open

Invalidate URI caches after component changes#613
OskarEichler wants to merge 1 commit into
sporkmonger:mainfrom
OskarEichler:codex/addressable-cache

Conversation

@OskarEichler

Copy link
Copy Markdown

Summary

Invalidate dependent normalization and composite caches when URI components change. Host changes could retain an old normalized authority; scheme changes could retain an old default-port decision. Reset site caches during destructive replacement too, preserving sentinel-based instance variables from #486.

Reproduction

require 'addressable'
uri = Addressable::URI.parse('https://one.example')
uri.normalize
uri.host = 'two.example'
p uri.normalize.to_s
# Before: https://one.example/; after: https://two.example/

Verification

  • Ruby 4.0.6 through rbenv; existing suite: 1,433 examples / 0 failures / 5 existing pending with pure Ruby IDNA, 1,466 examples / 0 failures / 5 existing pending with idn-ruby 0.1.5 + libidn.
  • 285 focused external assertions pass on this individual patch; the combined installed-release branch also passes all focused cases and both existing suites.
  • Comparative RuboCop Lint: 15 existing offenses before and after; no new offense (line references move). Syntax and git diff --check pass.

Compatibility and limitations

No intended breaking change. Corrects stale results after setters/merge!/join!/normalize!. Caches remain lazy; component strings and normalization rules are unchanged. This does not make externally mutated component strings safe or make URI instances thread-safe.

No dependency/version/data updates. No repository tests were added or changed: the commissioning repository explicitly prohibits new/modified tests, so reproduction checks run outside this repository. Other Ruby versions/platforms were not run locally; upstream CI may require maintainer approval. The existing normalization proposal #589 and IDNA2008 proposal #496 are separate and unchanged.

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