@opencode/util 0.0.0-dev-248 → 0.0.0-dev-256
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/path.js +4 -0
- package/package.json +1 -1
package/dist/path.js
CHANGED
|
@@ -24,11 +24,15 @@ export function getFilenameTruncated(path, maxLength = 20) {
|
|
|
24
24
|
return filename.slice(0, available) + "…" + extension;
|
|
25
25
|
}
|
|
26
26
|
export function truncateMiddle(text, maxLength = 20) {
|
|
27
|
+
if (maxLength <= 0)
|
|
28
|
+
return "";
|
|
27
29
|
if (text.length <= maxLength)
|
|
28
30
|
return text;
|
|
29
31
|
const available = maxLength - 1;
|
|
30
32
|
const start = Math.ceil(available / 2);
|
|
31
33
|
const end = Math.floor(available / 2);
|
|
34
|
+
if (end <= 0)
|
|
35
|
+
return text.slice(0, start) + "…";
|
|
32
36
|
return text.slice(0, start) + "…" + text.slice(-end);
|
|
33
37
|
}
|
|
34
38
|
const isDrive = (value) => {
|