@koloseum/utils 0.2.6 → 0.2.7
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.d.ts +13 -0
- package/dist/utils.js +25 -0
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -103,6 +103,19 @@ export declare const Utility: {
|
|
|
103
103
|
* @returns The formatted identity type string
|
|
104
104
|
*/
|
|
105
105
|
getIdentityTypeString: (identityType: IdentityType) => string;
|
|
106
|
+
/**
|
|
107
|
+
* Returns the URL for a menu item based on the slug.
|
|
108
|
+
* @param {string} base - The base URL
|
|
109
|
+
* @param {string} slug - The slug of the menu item
|
|
110
|
+
* @returns {string} The URL for the menu item
|
|
111
|
+
*/
|
|
112
|
+
getMenuItemUrl: (base: string, slug: string | undefined) => string;
|
|
113
|
+
/**
|
|
114
|
+
* Returns the parent URL for a given base URL.
|
|
115
|
+
* @param {string} base - The base URL
|
|
116
|
+
* @returns {string} The parent URL
|
|
117
|
+
*/
|
|
118
|
+
getParentUrl: (base: string) => string;
|
|
106
119
|
/**
|
|
107
120
|
* Returns a pronoun given pronouns and a type.
|
|
108
121
|
* @param {PronounsItem | null} pronouns - The pronouns to be formatted
|
package/dist/utils.js
CHANGED
|
@@ -328,6 +328,31 @@ export const Utility = {
|
|
|
328
328
|
return "Driver's licence";
|
|
329
329
|
return "";
|
|
330
330
|
},
|
|
331
|
+
/**
|
|
332
|
+
* Returns the URL for a menu item based on the slug.
|
|
333
|
+
* @param {string} base - The base URL
|
|
334
|
+
* @param {string} slug - The slug of the menu item
|
|
335
|
+
* @returns {string} The URL for the menu item
|
|
336
|
+
*/
|
|
337
|
+
getMenuItemUrl: (base, slug) => {
|
|
338
|
+
// Validate base URL
|
|
339
|
+
if (base === "" || typeof base !== "string")
|
|
340
|
+
return "";
|
|
341
|
+
// Return URL
|
|
342
|
+
return `${base}${slug && typeof slug === "string" ? `/${slug}` : ""}`;
|
|
343
|
+
},
|
|
344
|
+
/**
|
|
345
|
+
* Returns the parent URL for a given base URL.
|
|
346
|
+
* @param {string} base - The base URL
|
|
347
|
+
* @returns {string} The parent URL
|
|
348
|
+
*/
|
|
349
|
+
getParentUrl: (base) => {
|
|
350
|
+
// Validate input
|
|
351
|
+
if (base === "" || typeof base !== "string")
|
|
352
|
+
return "";
|
|
353
|
+
// Return parent URL
|
|
354
|
+
return base.replace(/\/$/, "").split("/").slice(0, -1).join("/") || "/";
|
|
355
|
+
},
|
|
331
356
|
/**
|
|
332
357
|
* Returns a pronoun given pronouns and a type.
|
|
333
358
|
* @param {PronounsItem | null} pronouns - The pronouns to be formatted
|