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
This commit is contained in:
parent
93c95dc8f7
commit
fd3d9838fe
@ -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(
|
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", () => {
|
it("uses inferred scope until the user overrides it", () => {
|
||||||
expect(
|
expect(
|
||||||
resolveBacklinksSearchScope({
|
resolveBacklinksSearchScope({
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export function inferBacklinksSearchScopeFromTarget(
|
|||||||
const parsed = new URL(
|
const parsed = new URL(
|
||||||
hasExplicitProtocol ? trimmed : `https://${trimmed}`,
|
hasExplicitProtocol ? trimmed : `https://${trimmed}`,
|
||||||
);
|
);
|
||||||
return hasExplicitProtocol || parsed.pathname !== "/" ? "page" : "domain";
|
return parsed.pathname !== "/" ? "page" : "domain";
|
||||||
} catch {
|
} catch {
|
||||||
return "domain";
|
return "domain";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user