diff --git a/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all/v2.ts b/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all/v2.ts index 862c0b1179..a735e470ef 100644 --- a/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all/v2.ts +++ b/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all/v2.ts @@ -6,7 +6,7 @@ import { NextApiHandler, NextApiRequest, NextApiResponse } from "next"; import urljoin from "url-join"; import { loadWithUrl } from "../../../../utils/loadWithUrl"; import { toValidPathname } from "../../../../utils/toValidPathname"; -import { isTrailingSlashEnabled } from "../../../../utils/trailingSlash"; +import { conformTrailingSlash } from "../../../../utils/trailingSlash"; import { cleanHost, getXFernHostNode } from "../../../../utils/xFernHost"; export const config = { @@ -66,9 +66,7 @@ const handler: NextApiHandler = async ( const node = FernNavigation.utils.convertLoadDocsForUrlResponse(docs); const slugCollector = NodeCollector.collect(node); - const urls = slugCollector - .getSlugs() - .map((slug) => urljoin(xFernHost, slug, isTrailingSlashEnabled() ? "/" : "")); + const urls = slugCollector.getSlugs().map((slug) => conformTrailingSlash(urljoin(xFernHost, slug))); // when we call res.revalidate() nextjs uses // req.headers.host to make the network request diff --git a/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all/v3.ts b/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all/v3.ts index 816dd6a53c..53257db8b5 100644 --- a/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all/v3.ts +++ b/packages/ui/docs-bundle/src/pages/api/fern-docs/revalidate-all/v3.ts @@ -7,7 +7,7 @@ import { NextApiHandler, NextApiRequest, NextApiResponse } from "next"; import urljoin from "url-join"; import { loadWithUrl } from "../../../../utils/loadWithUrl"; import { toValidPathname } from "../../../../utils/toValidPathname"; -import { isTrailingSlashEnabled } from "../../../../utils/trailingSlash"; +import { conformTrailingSlash } from "../../../../utils/trailingSlash"; import { getXFernHostNode } from "../../../../utils/xFernHost"; export const config = { @@ -76,9 +76,7 @@ const handler: NextApiHandler = async ( const node = FernNavigation.utils.convertLoadDocsForUrlResponse(docs); const slugCollector = NodeCollector.collect(node); - const urls = slugCollector - .getSlugs() - .map((slug) => urljoin(xFernHost, slug, isTrailingSlashEnabled() ? "/" : "")); + const urls = slugCollector.getSlugs().map((slug) => conformTrailingSlash(urljoin(xFernHost, slug))); // when we call res.revalidate() nextjs uses // req.headers.host to make the network request diff --git a/packages/ui/docs-bundle/src/pages/api/fern-docs/sitemap.xml.ts b/packages/ui/docs-bundle/src/pages/api/fern-docs/sitemap.xml.ts index 66cd193273..92318ec2b2 100644 --- a/packages/ui/docs-bundle/src/pages/api/fern-docs/sitemap.xml.ts +++ b/packages/ui/docs-bundle/src/pages/api/fern-docs/sitemap.xml.ts @@ -7,7 +7,7 @@ import { loadWithUrl } from "../../../utils/loadWithUrl"; import { getXFernHostEdge } from "../../../utils/xFernHost"; // eslint-disable-next-line import/no-internal-modules import { checkViewerAllowedEdge } from "@fern-ui/ui/auth"; -import { isTrailingSlashEnabled } from "../../../utils/trailingSlash"; +import { conformTrailingSlash } from "../../../utils/trailingSlash"; export const runtime = "edge"; export const revalidate = 60 * 60 * 24; @@ -37,7 +37,7 @@ export default async function GET(req: NextRequest): Promise { const slugCollector = NodeCollector.collect(node); const urls = slugCollector.getIndexablePageSlugs().map((slug) => urljoin(xFernHost, slug)); - const sitemap = getSitemapXml(urls.map((url) => (isTrailingSlashEnabled() ? `https://${url}/` : `https://${url}`))); + const sitemap = getSitemapXml(urls.map((url) => conformTrailingSlash(`https://${url}`))); headers.set("Content-Type", "text/xml");