-
Notifications
You must be signed in to change notification settings - Fork 295
Expand file tree
/
Copy pathutils.ts
More file actions
34 lines (27 loc) · 841 Bytes
/
utils.ts
File metadata and controls
34 lines (27 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import createDOMPurify from 'dompurify';
/**
* Sanitizes HTML string and allows only bold tags
*/
export const sanitizeMessage = (message: string): string => {
// Only run on client-side
if (typeof window === 'undefined') {
return message;
}
const purify = createDOMPurify(window);
// Configure DOMPurify to only allow <b> and <strong> tags
// and <br> tags for line breaks
return purify.sanitize(message, {
ALLOWED_TAGS: ['b', 'strong', 'br'],
ALLOWED_ATTR: [],
});
};
const brokenWebviewPatterns = [
/FBAN|FBAV/i, // Facebook App
/Messenger/i, // Facebook Messenger
/LinkedIn/i, // LinkedIn
];
export function shouldRedirectAuth(): boolean {
const ua = navigator.userAgent;
return brokenWebviewPatterns.some((pattern) => pattern.test(ua));
}
export const AUTH_REDIRECT_KEY = 'auth_redirect';