Skip to content

Commit

Permalink
Fix relative path in files util (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithmohan authored Apr 4, 2024
1 parent 41b9a58 commit f0a71ad
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/components/Utilities/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ export const staticColumns: UtilityHeaderType<FileType>[] = [
id: 'filename',
name: 'Filename',
className: 'line-clamp-2 grow basis-0 overflow-hidden',
item: file => (
<div className="flex flex-col" title={file.Locations[0]?.RelativePath.match(/[^\\]*$/)?.[0]}>
<span className="line-clamp-1 text-sm font-semibold opacity-65">
{file.Locations[0]?.RelativePath.match(/^(.*)\\/)?.[1] ?? 'Root Level'}
</span>
<span className="line-clamp-1">
{file.Locations[0]?.RelativePath?.split(/[/\\]/g)
.pop()}
</span>
</div>
),
item: (file) => {
const path = file.Locations[0]?.RelativePath ?? '';
const match = /[/\\](?=[^/\\]*$)/g.exec(path);
const relativePath = match ? path?.substring(0, match.index) : 'Root Level';
return (
<div className="flex flex-col" title={path}>
<span className="line-clamp-1 text-sm font-semibold opacity-65">
{relativePath}
</span>
<span className="line-clamp-1">
{path?.split(/[/\\]/g).pop()}
</span>
</div>
);
},
},
{
id: 'crc32',
Expand Down

0 comments on commit f0a71ad

Please sign in to comment.