-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(server): favicon resolution no longer pins the event loop #5531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -55,10 +55,12 @@ const ICON_SOURCE_FILES = [ | |||||
| ] as const; | ||||||
|
|
||||||
| // Matches <link ...> tags or object-like icon metadata where rel/href can appear in any order. | ||||||
| // Both patterns stay anchored on a literal opening delimiter (`<link` / `{`) so the scan starts | ||||||
| // only at real candidates and each attempt is bounded by the enclosing tag or object. | ||||||
| const LINK_ICON_HTML_RE = | ||||||
| /<link\b(?=[^>]*\brel=["'](?:icon|shortcut icon)["'])(?=[^>]*\bhref=["']([^"'?]+))[^>]*>/i; | ||||||
| const LINK_ICON_OBJ_RE = | ||||||
| /(?=[^}]*\brel\s*:\s*["'](?:icon|shortcut icon)["'])(?=[^}]*\bhref\s*:\s*["']([^"'?]+))[^}]*/i; | ||||||
| const LINK_ICON_OBJ_RE = /\{[^{}]*\brel\s*:\s*["'](?:icon|shortcut icon)["'][^{}]*\}/i; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium
Suggested change
🤖 Copy this AI Prompt to have your agent fix this: |
||||||
| const ICON_HREF_RE = /\bhref\s*:\s*["']([^"'?]+)/i; | ||||||
|
|
||||||
| export class ProjectFaviconResolutionError extends Schema.TaggedErrorClass<ProjectFaviconResolutionError>()( | ||||||
| "ProjectFaviconResolutionError", | ||||||
|
|
@@ -99,7 +101,8 @@ function extractIconHref(source: string): string | null { | |||||
| const htmlMatch = source.match(LINK_ICON_HTML_RE); | ||||||
| if (htmlMatch?.[1]) return htmlMatch[1]; | ||||||
| const objMatch = source.match(LINK_ICON_OBJ_RE); | ||||||
| if (objMatch?.[1]) return objMatch[1]; | ||||||
| const objHref = objMatch?.[0].match(ICON_HREF_RE); | ||||||
| if (objHref?.[1]) return objHref[1]; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skips later valid icon objectsMedium Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit 4b77158. Configure here. |
||||||
| return null; | ||||||
| } | ||||||
|
|
||||||
|
|
||||||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium
project/ProjectFaviconResolver.ts:62LINK_ICON_OBJ_REuses[^{}]*to bound the match, so any icon metadata object containing nested braces fails to match — for example{ attributes: {}, rel: "icon", href: "/favicon.svg" }returnsnullfromextractIconHrefinstead of/favicon.svg. The prior lookahead-based pattern could scan past inner braces; the new anchored pattern cannot. Consider using a pattern that tolerates nested braces, or strip/normalize brace depth before matching.🤖 Copy this AI Prompt to have your agent fix this: