Skip to content

Commit

Permalink
Remix does not ignore wildcard routes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlemTuzlak committed Jul 29, 2024
1 parent d48ca55 commit 9c9d2b6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@forge42/seo-tools",
"version": "1.2.1",
"version": "1.3.0",
"private": false,
"keywords": ["seo", "remix-seo", "seo-tools", "structured-data", "sitemap", "robots", "canonical", "seo-alternate"],
"description": "Framework agnostic set of helpers designed to help you create, maintain and develop your SEO",
Expand Down
35 changes: 35 additions & 0 deletions src/sitemap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,41 @@ describe("generateSitemap", () => {
).toEqual(expectedSitemap)
})

it("should ignore the url and use the sitemapEntries when it's provided for an entry even if the path is `*`", async () => {
const expectedSitemap = removeWhitespace(`
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-news/0.9 http://www.google.com/schemas/sitemap-news/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-video/1.1 http://www.google.com/schemas/sitemap-video/1.1/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap.xsd http://www.w3.org/TR/xhtml11/xhtml11_schema.html http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:xhtml="http://www.w3.org/TR/xhtml11/xhtml11_schema.html" >
<url>
<loc>https://example.com/page2</loc>
</url>
<url>
<loc>another-wildcard-route</loc>
</url>
</urlset>
`)
expect(
removeWhitespace(
await generateSitemap({
routes: [
{
url: "*",

sitemapEntries: [
{
route: "https://example.com/page2",
},
{
route: "another-wildcard-route",
},
],
},
],
domain: "https://example.com",
})
)
).toEqual(expectedSitemap)
})

it("should ignore the url and use the sitemapEntries when it's provided for an entry and it should loop over all the entries and add all their additional properties", async () => {
const expectedSitemap = removeWhitespace(`
<?xml version="1.0" encoding="UTF-8"?>
Expand Down
2 changes: 1 addition & 1 deletion src/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const generateSitemapEntriesFromRoutes = ({
const finalLocation = route.url.startsWith("/") ? route.url : `/${route.url}`

// If the route matches any ignored pattern ignore it completely
if (ignore.some((pattern) => new UrlPattern(pattern).match(finalLocation) !== null) || route.url === "*") {
if (ignore.some((pattern) => new UrlPattern(pattern).match(finalLocation) !== null)) {
return ""
}

Expand Down

0 comments on commit 9c9d2b6

Please sign in to comment.