Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Fix domain result links to preserve subdomains (#641)
Ben Senescud648d2df5451
diff --git a/src/client/features/domain/components/DomainKeywordsTable.tsx b/src/client/features/domain/components/DomainKeywordsTable.tsxindex cbaeff85..0b8a583e 100644--- a/src/client/features/domain/components/DomainKeywordsTable.tsx+++ b/src/client/features/domain/components/DomainKeywordsTable.tsx@@ -115,7 +115,7 @@ function DomainKeywordsTableComponent({header: () => "URL",cell: ({ row }) => (<ExternalUrlCell- value={row.original.relativeUrl ?? row.original.url}+ value={row.original.url || row.original.relativeUrl}label={row.original.relativeUrl ?? row.original.url ?? ""}baseDomain={domain}/>diff --git a/src/client/features/domain/components/DomainPagesTable.tsx b/src/client/features/domain/components/DomainPagesTable.tsxindex c574a99d..229abd95 100644--- a/src/client/features/domain/components/DomainPagesTable.tsx+++ b/src/client/features/domain/components/DomainPagesTable.tsx@@ -43,7 +43,7 @@ function DomainPagesTableComponent({header: () => "Page",cell: ({ row }) => (<ExternalUrlCell- value={row.original.relativePath ?? row.original.page}+ value={row.original.page}label={row.original.relativePath ?? row.original.page}baseDomain={domain}className="link link-primary inline-flex items-center gap-1"diff --git a/src/client/features/domain/components/domainResultLinks.test.ts b/src/client/features/domain/components/domainResultLinks.test.tsnew file mode 100644index 00000000..b2918570--- /dev/null+++ b/src/client/features/domain/components/domainResultLinks.test.ts@@ -0,0 +1,75 @@+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { load } from "cheerio";+import { describe, expect, it, vi } from "vitest";+import { DomainPagesTable } from "./DomainPagesTable";+import { DomainKeywordsTable } from "./DomainKeywordsTable";++const tableProps = {+ domain: "zumvu.com",+ sortMode: "traffic" as const,+ currentSortOrder: "desc" as const,+ onSortClick: vi.fn(),+};++describe("domain result links", () => {+ it.each([+ "https://blog.zumvu.com/pounds-to-ounces/",+ "http://blog.zumvu.com/pounds-to-ounces/?unit=oz#calculator",+ "https://zumvu.com/pounds-to-ounces/",+ ])("links Top Pages to the original URL: %s", (page) => {+ const $ = load(+ renderToStaticMarkup(+ createElement(DomainPagesTable, {+ ...tableProps,+ rows: [+ {+ page,+ relativePath: "/pounds-to-ounces/",+ organicTraffic: 100,+ keywords: 10,+ },+ ],+ }),+ ),+ );++ expect($("tbody a").attr("href")).toBe(page);+ expect($("tbody a").text()).toBe("/pounds-to-ounces/");+ });++ it.each([+ [+ "https://blog.zumvu.com/pounds-to-ounces/",+ "https://blog.zumvu.com/pounds-to-ounces/",+ ],+ [null, "https://zumvu.com/pounds-to-ounces/"],+ ["", "https://zumvu.com/pounds-to-ounces/"],+ ])("links Top Keywords with URL %s", (url, expectedHref) => {+ const $ = load(+ renderToStaticMarkup(+ createElement(DomainKeywordsTable, {+ ...tableProps,+ selectedKeywords: new Set<string>(),+ visibleKeywords: ["pounds to ounces"],+ onToggleKeyword: vi.fn(),+ rows: [+ {+ keyword: "pounds to ounces",+ position: 1,+ searchVolume: 100,+ traffic: 10,+ cpc: null,+ url,+ relativeUrl: "/pounds-to-ounces/",+ keywordDifficulty: null,+ },+ ],+ }),+ ),+ );++ expect($("tbody a").attr("href")).toBe(expectedHref);+ expect($("tbody a").text()).toBe("/pounds-to-ounces/");+ });+});