@doyourjob/gravity-ui-page-constructor 5.31.120 → 5.31.121

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.
@@ -8,6 +8,6 @@ export declare enum FileExtension {
8
8
  FIG = "fig",
9
9
  ZIP = "zip"
10
10
  }
11
- export declare function getFileExt(name: string): string;
11
+ export declare function getFileExt(name?: string): FileExtension | undefined;
12
12
  declare const FileLink: (props: React.PropsWithChildren<FileLinkProps>) => JSX.Element;
13
13
  export default FileLink;
@@ -18,11 +18,28 @@ var FileExtension;
18
18
  FileExtension["ZIP"] = "zip";
19
19
  })(FileExtension = exports.FileExtension || (exports.FileExtension = {}));
20
20
  function getFileExt(name) {
21
- if (name === null || name === void 0 ? void 0 : name.includes(FIGMA_URL)) {
21
+ var _a;
22
+ if (!name)
23
+ return undefined;
24
+ if (name.includes(FIGMA_URL)) {
22
25
  return FileExtension.FIG;
23
26
  }
24
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
25
- return name && name.split('.').pop().toLowerCase();
27
+ let pathname = name;
28
+ try {
29
+ const url = new URL(name);
30
+ pathname = url.pathname;
31
+ }
32
+ catch (_b) { }
33
+ const parts = pathname.trim().split('.');
34
+ if (parts.length < 2)
35
+ return undefined;
36
+ const ext = (_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
37
+ if (!ext)
38
+ return undefined;
39
+ if (Object.values(FileExtension).includes(ext)) {
40
+ return ext;
41
+ }
42
+ return undefined;
26
43
  }
27
44
  exports.getFileExt = getFileExt;
28
45
  const FileExtensionThemes = {
@@ -9,6 +9,6 @@ export declare enum FileExtension {
9
9
  FIG = "fig",
10
10
  ZIP = "zip"
11
11
  }
12
- export declare function getFileExt(name: string): string;
12
+ export declare function getFileExt(name?: string): FileExtension | undefined;
13
13
  declare const FileLink: (props: React.PropsWithChildren<FileLinkProps>) => JSX.Element;
14
14
  export default FileLink;
@@ -15,11 +15,28 @@ export var FileExtension;
15
15
  FileExtension["ZIP"] = "zip";
16
16
  })(FileExtension || (FileExtension = {}));
17
17
  export function getFileExt(name) {
18
- if (name === null || name === void 0 ? void 0 : name.includes(FIGMA_URL)) {
18
+ var _a;
19
+ if (!name)
20
+ return undefined;
21
+ if (name.includes(FIGMA_URL)) {
19
22
  return FileExtension.FIG;
20
23
  }
21
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
- return name && name.split('.').pop().toLowerCase();
24
+ let pathname = name;
25
+ try {
26
+ const url = new URL(name);
27
+ pathname = url.pathname;
28
+ }
29
+ catch (_b) { }
30
+ const parts = pathname.trim().split('.');
31
+ if (parts.length < 2)
32
+ return undefined;
33
+ const ext = (_a = parts.pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
34
+ if (!ext)
35
+ return undefined;
36
+ if (Object.values(FileExtension).includes(ext)) {
37
+ return ext;
38
+ }
39
+ return undefined;
23
40
  }
24
41
  const FileExtensionThemes = {
25
42
  [FileExtension.PDF]: 'danger',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor",
3
- "version": "5.31.120",
3
+ "version": "5.31.121",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {