@koloseum/utils 0.2.17 → 0.2.19
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/utils.js +7 -4
- package/package.json +10 -10
package/dist/utils.js
CHANGED
|
@@ -6,8 +6,6 @@ import validator from "validator";
|
|
|
6
6
|
const parsePgInterval = (await import("postgres-interval")).default;
|
|
7
7
|
const sanitize = (await import("sanitize-html")).default;
|
|
8
8
|
const { trim, escape, isMobilePhone, isURL } = validator;
|
|
9
|
-
// Cache constants
|
|
10
|
-
const DEFAULT_TTL = 3600; // 1 hour in seconds
|
|
11
9
|
const { KenyaAdministrativeDivisions } = (await import("kenya-administrative-divisions")).default;
|
|
12
10
|
/* DUMMY DATA */
|
|
13
11
|
export const Data = {
|
|
@@ -387,8 +385,13 @@ export const Utility = {
|
|
|
387
385
|
// Validate base URL
|
|
388
386
|
if (typeof base !== "string")
|
|
389
387
|
return "";
|
|
388
|
+
// Format base URL
|
|
389
|
+
if (base === "/")
|
|
390
|
+
base = "";
|
|
391
|
+
if (base.charAt(base.length - 1) === "/")
|
|
392
|
+
base = base.slice(0, -1);
|
|
390
393
|
// Return URL
|
|
391
|
-
return `${base}${slug
|
|
394
|
+
return `${base}${slug === "/" ? slug : typeof slug === "string" ? `/${slug}` : ""}`;
|
|
392
395
|
},
|
|
393
396
|
/**
|
|
394
397
|
* Returns the parent URL for a given base URL.
|
|
@@ -1573,7 +1576,7 @@ export const Cache = {
|
|
|
1573
1576
|
* @param data - The data to cache
|
|
1574
1577
|
* @param ttl - The time to live in seconds; defaults to 1 hour
|
|
1575
1578
|
*/
|
|
1576
|
-
setData: async (valkey, cachePrefix, key, data, ttl =
|
|
1579
|
+
setData: async (valkey, cachePrefix, key, data, ttl = 3600) => {
|
|
1577
1580
|
try {
|
|
1578
1581
|
await valkey.setex(`${cachePrefix}${key}`, ttl, JSON.stringify(data));
|
|
1579
1582
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koloseum/utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.19",
|
|
4
4
|
"author": "Koloseum Technologies Limited",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Utility logic for use across Koloseum web apps (TypeScript)",
|
|
@@ -29,23 +29,23 @@
|
|
|
29
29
|
"test": "vitest --run"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@supabase/supabase-js": "^2.
|
|
33
|
-
"@sveltejs/kit": "^2.
|
|
32
|
+
"@supabase/supabase-js": "^2.57.4",
|
|
33
|
+
"@sveltejs/kit": "^2.41.0",
|
|
34
34
|
"kenya-administrative-divisions": "^0.0.18",
|
|
35
35
|
"postgres-interval": "^4.0.2",
|
|
36
36
|
"sanitize-html": "^2.17.0",
|
|
37
|
-
"uuid": "^
|
|
37
|
+
"uuid": "^13.0.0",
|
|
38
38
|
"validator": "^13.15.15"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@koloseum/types": "^0.2.
|
|
42
|
-
"@playwright/test": "^1.
|
|
43
|
-
"@suprsend/web-components": "^0.
|
|
41
|
+
"@koloseum/types": "^0.2.6",
|
|
42
|
+
"@playwright/test": "^1.55.0",
|
|
43
|
+
"@suprsend/web-components": "^0.4.0",
|
|
44
44
|
"@types/sanitize-html": "^2.16.0",
|
|
45
45
|
"@types/uuid": "^10.0.0",
|
|
46
|
-
"@types/validator": "^13.15.
|
|
47
|
-
"prettier": "^3.6.
|
|
48
|
-
"typescript": "^5.
|
|
46
|
+
"@types/validator": "^13.15.3",
|
|
47
|
+
"prettier": "^3.6.2",
|
|
48
|
+
"typescript": "^5.9.2",
|
|
49
49
|
"vitest": "^3.2.4"
|
|
50
50
|
}
|
|
51
51
|
}
|