Skip to content

Commit d46c94c

Browse files
fix(server): trim icon hrefs before resolving favicon candidates
The shared workspace path resolver no longer trims, so HTML icon hrefs with surrounding whitespace stopped matching. Browsers ignore that whitespace, so the favicon resolver strips it before building paths. AI-assisted; verified with the tests and tools listed above.
1 parent 20b95d7 commit d46c94c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎apps/server/src/project/ProjectFaviconResolver.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ it.layer(layerTest)("ProjectFaviconResolverLive", (it) => {
201201

202202
expect(resolved).not.toBeNull();
203203
expect(resolved).toBe((yield* Path.Path).join(cwd, "public", "brand", "logo.svg"));
204+
205+
const paddedCwd = yield* makeTempDir;
206+
yield* writeTextFile(
207+
paddedCwd,
208+
"index.html",
209+
'<link rel="icon" href=" brand/custom.svg ">',
210+
);
211+
yield* writeTextFile(paddedCwd, "brand/custom.svg", "<svg>custom</svg>");
212+
expect(yield* resolver.resolvePath(paddedCwd)).toBe(
213+
(yield* Path.Path).join(paddedCwd, "brand", "custom.svg"),
214+
);
204215
}),
205216
);
206217

‎apps/server/src/project/ProjectFaviconResolver.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ export const make = Effect.gen(function* () {
144144
const projectFileLoader = yield* T3ProjectFileLoader.T3ProjectFileLoader;
145145

146146
const resolveIconHref = (href: string): ReadonlyArray<string> => {
147-
const clean = href.replace(/^\//, "");
147+
// Browsers strip surrounding whitespace from URL attributes; file paths keep theirs.
148+
const clean = href.trim().replace(/^\//, "");
148149
return [path.join("public", clean), clean];
149150
};
150151

0 commit comments

Comments
 (0)