Skip to content

Open source alternative to Semrush and Ahrefs

fix: default backlinks search to site-wide scope for root URLs (#96)

Ben Senescufd3d9838fe19
diff --git a/src/client/features/backlinks/backlinksSearchScope.test.ts b/src/client/features/backlinks/backlinksSearchScope.test.ts
index 2f0fb221..3a024c1a 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 4219574b..dad8e5be 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";
}