@aspan-corporation/ac-shared 1.2.21 → 1.2.23

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.
@@ -36,9 +36,13 @@ export const processMeta = async ({ id, meta, metaTableName, size, logger, locat
36
36
  ...(meta.find((tag) => tag.key === "dateCreated")
37
37
  ? []
38
38
  : extractMetaFromKey(id)),
39
- { key: "extension", value: getKeyExtension(id) },
40
- { key: "size", value: String(size) },
41
- { key: "sizeMb", value: String(Math.round(size / 1024 ** 2)) },
39
+ ...(id.endsWith("/")
40
+ ? []
41
+ : [
42
+ { key: "extension", value: getKeyExtension(id) },
43
+ { key: "size", value: String(size) },
44
+ { key: "sizeMb", value: String(Math.round(size / 1024 ** 2)) },
45
+ ]),
42
46
  ...(geoPositionResult?.Place?.Label
43
47
  ? [{ key: "label", value: geoPositionResult?.Place?.Label }]
44
48
  : []),
@@ -11,6 +11,7 @@ export declare const DIM_THUMBNAIL_WIDTH = 320;
11
11
  export declare const DIM_THUMBNAIL_HEIGHT = 320;
12
12
  export declare const DIM_DETAIL_WIDTH = 1180;
13
13
  export declare const DIM_DETAIL_HEIGHT = 820;
14
+ export declare const getKeyExtension: (key: string) => string;
14
15
  export declare const getThumbnailKey: ({ key, width, height }: {
15
16
  key: string;
16
17
  width: number;
@@ -19,6 +20,5 @@ export declare const getThumbnailKey: ({ key, width, height }: {
19
20
  export declare const getEncodedVideoKey: ({ key }: {
20
21
  key: string;
21
22
  }) => string;
22
- export declare const getKeyExtension: (key: string) => string;
23
23
  export declare const isAllowedExtension: (key: string) => boolean;
24
24
  export declare const isAllowedVideoExtension: (key: string) => boolean;
@@ -1,4 +1,3 @@
1
- import { extname, basename, dirname } from "node:path";
2
1
  export const EXTENSION_JPEG = "jpeg";
3
2
  export const EXTENSION_JPG = "jpg";
4
3
  export const EXTENSION_WEBP = "webp";
@@ -17,7 +16,14 @@ export const DIM_THUMBNAIL_HEIGHT = 320;
17
16
  export const DIM_DETAIL_WIDTH = 1180;
18
17
  export const DIM_DETAIL_HEIGHT = 820;
19
18
  const getPathNameWithoutExt = (key) => {
20
- return dirname(key) + "/" + basename(key, extname(key));
19
+ const lastDot = key.lastIndexOf(".");
20
+ const lastSlash = key.lastIndexOf("/");
21
+ return lastDot > lastSlash ? key.slice(0, lastDot) : key;
22
+ };
23
+ export const getKeyExtension = (key) => {
24
+ const lastDot = key.lastIndexOf(".");
25
+ const lastSlash = key.lastIndexOf("/");
26
+ return lastDot > lastSlash ? key.slice(lastDot + 1).toLowerCase() : "";
21
27
  };
22
28
  export const getThumbnailKey = ({ key, width, height }) => {
23
29
  return (getPathNameWithoutExt(key) +
@@ -31,7 +37,6 @@ export const getThumbnailKey = ({ key, width, height }) => {
31
37
  export const getEncodedVideoKey = ({ key }) => {
32
38
  return getPathNameWithoutExt(key) + "." + EXTENSION_ENCODED_VIDEO;
33
39
  };
34
- export const getKeyExtension = (key) => extname(key).slice(1).toLowerCase();
35
40
  export const isAllowedExtension = (key) => {
36
41
  const ext = getKeyExtension(key);
37
42
  return ALLOWED_EXTENSIONS.includes(ext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspan-corporation/ac-shared",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "exports": {
@@ -19,6 +19,10 @@
19
19
  "./utils": {
20
20
  "types": "./lib/utils/index.d.ts",
21
21
  "import": "./lib/utils/index.js"
22
+ },
23
+ "./utils/thumbsKey": {
24
+ "types": "./lib/utils/thumbsKey.d.ts",
25
+ "import": "./lib/utils/thumbsKey.js"
22
26
  }
23
27
  },
24
28
  "author": "",