Skip to content

Add SPA-aware url Svelte store that ignores hash changes#9858

Closed
fregante with Copilot wants to merge 10 commits into
mainfrom
copilot/implement-url-tracking-store
Closed

Add SPA-aware url Svelte store that ignores hash changes#9858
fregante with Copilot wants to merge 10 commits into
mainfrom
copilot/implement-url-tracking-store

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Adds a new Svelte store under source/components to track the current GitHub page URL in SPA navigation flows. The stored value is hashless, and hash-only transitions do not trigger updates.

  • Store implementation

    • Added source/components/url.ts with a readable store that normalizes URL values by removing #....
    • Exposes the current canonical URL (including pathname/search, excluding hash).
  • SPA navigation coverage

    • Updates on history.pushState, history.replaceState, and popstate.
    • Also listens to navigation.navigate when the Navigation API is available.
  • Update semantics

    • Emits only when the normalized URL changes, so fragment-only changes are ignored.
function normalizeUrl(url: string): string {
	const parsed = new URL(url, location.origin);
	parsed.hash = '';
	return parsed.href;
}
  • Tests
    • Added source/components/url.test.ts covering:
      • initial hash stripping
      • push/replace updates
      • hash-only no-op behavior
      • popstate handling
      • Navigation API handling

Test URLs

Screenshot

Copilot AI changed the title [WIP] Add Svelte store for URL tracking Add SPA-aware url Svelte store that ignores hash changes Jul 18, 2026
Copilot AI requested a review from fregante July 18, 2026 16:47
@fregante fregante closed this Jul 18, 2026
@fregante
fregante deleted the copilot/implement-url-tracking-store branch July 18, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants