change modal on error
This commit is contained in:
@@ -7,6 +7,14 @@
|
||||
* See LICENSE file in repository root for details.
|
||||
*/
|
||||
|
||||
const RESOURCE_ACCESS_ERROR_PATTERN = /(?:invalid password|password required|authentication required|access expired or revoked)/i;
|
||||
|
||||
export function isResourceAccessError(error) {
|
||||
const status = Number(error?.status);
|
||||
const message = typeof error === "string" ? error : error?.message;
|
||||
return status === 401 || RESOURCE_ACCESS_ERROR_PATTERN.test(String(message || ""));
|
||||
}
|
||||
|
||||
export function safeAppUrl(value, fallback = "/") {
|
||||
try {
|
||||
const url = new URL(String(value || ""), location.origin);
|
||||
|
||||
Reference in New Issue
Block a user