Skip to content

Commit

Permalink
feat: print package name with version suffix
Browse files Browse the repository at this point in the history
Closes: #206
Signed-off-by: Zxilly <[email protected]>
  • Loading branch information
Zxilly committed Aug 29, 2024
1 parent 58ac937 commit e36546f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ui/src/Node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,17 @@ function getTransform(scale: number): string | undefined {
}

const splitter = /[/\\]/;
const verMatcher = /v\d+/;

function getLastWord(title: string): string {
function getShortName(title: string): string {
const words = title.split(splitter);
const last = words[words.length - 1];

if (words.length >= 2 && verMatcher.test(last)) {
const split = title[title.length - last.length - 1];
return `${words[words.length - 2]}${split}${last}`;
}

return words[words.length - 1];
}

Expand Down Expand Up @@ -112,7 +120,7 @@ export const Node: React.FC<NodeProps> = React.memo((
}

if (scale < 0.7 && fallback) {
return getScale(getLastWord(title), false);
return getScale(getShortName(title), false);
}
return [title, scale];
}, [hasChildren, height, width]);
Expand Down

0 comments on commit e36546f

Please sign in to comment.