| ... | ... | @@ -115,4 +115,41 @@ describe("tryHandleProjectFaviconRequest", () => { |
| 115 | 115 | expect(response.body).toBe("<svg>brand</svg>"); |
| 116 | 116 | }); |
| 117 | 117 | }); |
| 118 | |
| 119 | it("resolves icon link when href appears before rel in HTML", async () => { |
| 120 | const projectDir = makeTempDir("t3code-favicon-route-html-order-"); |
| 121 | const iconPath = path.join(projectDir, "public", "brand", "logo.svg"); |
| 122 | fs.mkdirSync(path.dirname(iconPath), { recursive: true }); |
| 123 | fs.writeFileSync(path.join(projectDir, "index.html"), '<link href="/brand/logo.svg" rel="icon">'); |
| 124 | fs.writeFileSync(iconPath, "<svg>brand-html-order</svg>", "utf8"); |
| 125 | |
| 126 | await withRouteServer(async (baseUrl) => { |
| 127 | const pathname = `/api/project-favicon?cwd=${encodeURIComponent(projectDir)}`; |
| 128 | const response = await request(baseUrl, pathname); |
| 129 | expect(response.statusCode).toBe(200); |
| 130 | expect(response.contentType).toContain("image/svg+xml"); |
| 131 | expect(response.body).toBe("<svg>brand-html-order</svg>"); |
| 132 | }); |
| 133 | }); |
| 134 | |
| 135 | it("resolves object-style icon metadata when href appears before rel", async () => { |
| 136 | const projectDir = makeTempDir("t3code-favicon-route-obj-order-"); |
| 137 | const iconPath = path.join(projectDir, "public", "brand", "obj.svg"); |
| 138 | fs.mkdirSync(path.dirname(iconPath), { recursive: true }); |
| 139 | fs.mkdirSync(path.join(projectDir, "src"), { recursive: true }); |
| 140 | fs.writeFileSync( |
| 141 | path.join(projectDir, "src", "root.tsx"), |
| 142 | 'const links = [{ href: "/brand/obj.svg", rel: "icon" }];', |
| 143 | "utf8", |
| 144 | ); |
| 145 | fs.writeFileSync(iconPath, "<svg>brand-obj-order</svg>", "utf8"); |
| 146 | |
| 147 | await withRouteServer(async (baseUrl) => { |
| 148 | const pathname = `/api/project-favicon?cwd=${encodeURIComponent(projectDir)}`; |
| 149 | const response = await request(baseUrl, pathname); |
| 150 | expect(response.statusCode).toBe(200); |
| 151 | expect(response.contentType).toContain("image/svg+xml"); |
| 152 | expect(response.body).toBe("<svg>brand-obj-order</svg>"); |
| 153 | }); |
| 154 | }); |
| 118 | 155 | }); |