@koloseum/utils 0.3.1 → 0.3.2
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/platform.d.ts +7 -0
- package/dist/platform.js +23 -0
- package/package.json +2 -2
package/dist/platform.d.ts
CHANGED
|
@@ -71,6 +71,13 @@ export declare const Resource: {
|
|
|
71
71
|
url: URL;
|
|
72
72
|
path?: string;
|
|
73
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Resolves a redirect URI.
|
|
76
|
+
* @param redirectUri - The redirect URI
|
|
77
|
+
* @param isDev - Whether the environment is development; defaults to `false`
|
|
78
|
+
* @returns A resolved redirect URL, or `undefined` if the redirect URI is invalid
|
|
79
|
+
*/
|
|
80
|
+
resolveRedirectUri: (redirectUri: string | null, isDev?: boolean) => string | undefined;
|
|
74
81
|
/**
|
|
75
82
|
* Validates address data submitted in a form and returns the validated data.
|
|
76
83
|
* @param {FormData} formData - The submitted form data
|
package/dist/platform.js
CHANGED
|
@@ -702,6 +702,29 @@ export const Resource = {
|
|
|
702
702
|
// Return the request URL and path
|
|
703
703
|
return { url, path };
|
|
704
704
|
},
|
|
705
|
+
/**
|
|
706
|
+
* Resolves a redirect URI.
|
|
707
|
+
* @param redirectUri - The redirect URI
|
|
708
|
+
* @param isDev - Whether the environment is development; defaults to `false`
|
|
709
|
+
* @returns A resolved redirect URL, or `undefined` if the redirect URI is invalid
|
|
710
|
+
*/
|
|
711
|
+
resolveRedirectUri: (redirectUri, isDev = false) => {
|
|
712
|
+
// Return undefined if no input
|
|
713
|
+
if (!redirectUri)
|
|
714
|
+
return undefined;
|
|
715
|
+
// Get safe redirect URL
|
|
716
|
+
const result = Resource.getSafeRedirectUrl(redirectUri, isDev);
|
|
717
|
+
if (result && "url" in result && result.url)
|
|
718
|
+
return result.url;
|
|
719
|
+
// Return redirect URI if it is a valid path-relative URL
|
|
720
|
+
if (redirectUri.startsWith("/") && !redirectUri.startsWith("//"))
|
|
721
|
+
return redirectUri;
|
|
722
|
+
// Return redirect URI if it is a valid redirect URL
|
|
723
|
+
if (Resource.validateRedirectUrl(redirectUri, isDev))
|
|
724
|
+
return redirectUri;
|
|
725
|
+
// Return undefined if the redirect URI is invalid
|
|
726
|
+
return undefined;
|
|
727
|
+
},
|
|
705
728
|
/**
|
|
706
729
|
* Validates address data submitted in a form and returns the validated data.
|
|
707
730
|
* @param {FormData} formData - The submitted form data
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koloseum/utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"author": "Koloseum Technologies Limited",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Utility logic for use across Koloseum web apps (TypeScript)",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"validator": "^13.15.15"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@koloseum/types": "^0.
|
|
64
|
+
"@koloseum/types": "^0.3.0",
|
|
65
65
|
"@playwright/test": "^1.55.0",
|
|
66
66
|
"@suprsend/web-components": "^0.4.0",
|
|
67
67
|
"@types/sanitize-html": "^2.16.0",
|