@astral/ui 4.92.1 → 4.92.3
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.
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { findExtension } from '../findExtension';
|
|
2
2
|
import { SUFFIX_LENGTH } from './constants';
|
|
3
3
|
export const truncateString = (fileName) => {
|
|
4
|
-
const fileExtension = findExtension(fileName);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const fileExtension = findExtension(fileName) || '';
|
|
5
|
+
const nameWithoutExt = fileName.slice(0, fileName.length - fileExtension.length);
|
|
6
|
+
if (nameWithoutExt.length <= SUFFIX_LENGTH) {
|
|
7
|
+
return {
|
|
8
|
+
baseName: '',
|
|
9
|
+
suffixWithExtension: fileName,
|
|
10
|
+
};
|
|
9
11
|
}
|
|
10
|
-
const baseName =
|
|
11
|
-
const suffixWithExtension = fileName.slice(
|
|
12
|
+
const baseName = nameWithoutExt.slice(0, nameWithoutExt.length - SUFFIX_LENGTH);
|
|
13
|
+
const suffixWithExtension = fileName.slice(baseName.length);
|
|
12
14
|
return { baseName, suffixWithExtension };
|
|
13
15
|
};
|
|
@@ -4,14 +4,16 @@ exports.truncateString = void 0;
|
|
|
4
4
|
const findExtension_1 = require("../findExtension");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const truncateString = (fileName) => {
|
|
7
|
-
const fileExtension = (0, findExtension_1.findExtension)(fileName);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
const fileExtension = (0, findExtension_1.findExtension)(fileName) || '';
|
|
8
|
+
const nameWithoutExt = fileName.slice(0, fileName.length - fileExtension.length);
|
|
9
|
+
if (nameWithoutExt.length <= constants_1.SUFFIX_LENGTH) {
|
|
10
|
+
return {
|
|
11
|
+
baseName: '',
|
|
12
|
+
suffixWithExtension: fileName,
|
|
13
|
+
};
|
|
12
14
|
}
|
|
13
|
-
const baseName =
|
|
14
|
-
const suffixWithExtension = fileName.slice(
|
|
15
|
+
const baseName = nameWithoutExt.slice(0, nameWithoutExt.length - constants_1.SUFFIX_LENGTH);
|
|
16
|
+
const suffixWithExtension = fileName.slice(baseName.length);
|
|
15
17
|
return { baseName, suffixWithExtension };
|
|
16
18
|
};
|
|
17
19
|
exports.truncateString = truncateString;
|