Skip to content

Commit 7686e08

Browse files
fix: add type guard to prevent crash with 'constructor' folder name
Fixes #861 When a folder is named 'constructor', getIconForFolder returns an object (Object.prototype.constructor) instead of a string, causing a runtime error when calling .indexOf() on it. Added a type check to ensure the icon is a string before processing. Co-authored-by: Brendan Kellam <brendan-kellam@users.noreply.github.com>
1 parent fec4211 commit 7686e08

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/web/src/app/components/vscodeFolderIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface VscodeFolderIconProps {
1313
export const VscodeFolderIcon = ({ folderName, className }: VscodeFolderIconProps) => {
1414
const iconName = useMemo(() => {
1515
const icon = getIconForFolder(folderName);
16-
if (icon) {
16+
if (icon && typeof icon === 'string') {
1717
const iconName = `vscode-icons:${icon.substring(0, icon.indexOf('.')).replaceAll('_', '-')}`;
1818
return iconName;
1919
}

0 commit comments

Comments
 (0)