From fd3d9838fe19617ce75f94363ad8438ad456b136 Mon Sep 17 00:00:00 2001 From: Ben Senescu <44480372+bensenescu@users.noreply.github.com> Date: Tue, 7 Apr 2026 23:51:39 -0400 Subject: [PATCH] fix: default backlinks search to site-wide scope for root URLs (#96) * fix: default backlinks search to site-wide scope for root URLs URLs with an explicit protocol but no path (e.g. https://example.com/) were incorrectly auto-selecting "Exact page" scope. Now only URLs with an actual path beyond "/" trigger page scope auto-selection. * test: update backlinks scope tests for root URL behavior change --- .../features/backlinks/backlinksSearchScope.test.ts | 10 ++++++++-- src/client/features/backlinks/backlinksSearchScope.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/client/features/backlinks/backlinksSearchScope.test.ts b/src/client/features/backlinks/backlinksSearchScope.test.ts index 2f0fb22..3a024c1 100644 --- a/src/client/features/backlinks/backlinksSearchScope.test.ts +++ b/src/client/features/backlinks/backlinksSearchScope.test.ts @@ -16,12 +16,18 @@ describe("inferBacklinksSearchScopeFromTarget", () => { ); }); - it("treats explicit urls as page lookups", () => { + it("treats root urls with explicit protocol as domain lookups", () => { expect(inferBacklinksSearchScopeFromTarget("https://example.com/")).toBe( - "page", + "domain", ); }); + it("treats explicit urls with a path as page lookups", () => { + expect( + inferBacklinksSearchScopeFromTarget("https://example.com/pricing"), + ).toBe("page"); + }); + it("uses inferred scope until the user overrides it", () => { expect( resolveBacklinksSearchScope({ diff --git a/src/client/features/backlinks/backlinksSearchScope.ts b/src/client/features/backlinks/backlinksSearchScope.ts index 4219574..dad8e5b 100644 --- a/src/client/features/backlinks/backlinksSearchScope.ts +++ b/src/client/features/backlinks/backlinksSearchScope.ts @@ -14,7 +14,7 @@ export function inferBacklinksSearchScopeFromTarget( const parsed = new URL( hasExplicitProtocol ? trimmed : `https://${trimmed}`, ); - return hasExplicitProtocol || parsed.pathname !== "/" ? "page" : "domain"; + return parsed.pathname !== "/" ? "page" : "domain"; } catch { return "domain"; }