forked from jsonwebtoken/jsonwebtoken.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
53 lines (43 loc) · 1.31 KB
/
Copy pathutils.js
File metadata and controls
53 lines (43 loc) · 1.31 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as Bowser from 'bowser';
import { isWideScreen } from '../utils.js';
import {
algorithmSelect,
algorithmEs512,
editorElement,
decodedElement
} from '../dom-elements.js';
const browser = Bowser.parse(window.navigator.userAgent);
export function getTrimmedValue(instance) {
const value = instance.getValue();
if (!value) {
return '';
}
return value.replace(/\s/g, '');
}
export function fixEditorHeight() {
if(isWideScreen()) {
editorElement.style.height = `${decodedElement.offsetHeight}px`;
}
}
export const stringifyIndentSpaces = 2;
export function stringify(object) {
return JSON.stringify(object, null, stringifyIndentSpaces);
}
export function getSelectedAlgorithm() {
const selected = algorithmSelect.options[algorithmSelect.selectedIndex];
return selected.value;
}
export function p521Supported() {
return browser.engine.name !== 'WebKit' ||
(browser.browser.name === 'Safari' && parseInt(browser.browser.version, 10) >= 15) ||
(browser.os.name === 'iOS' && parseInt(browser.os.version, 10) >= 15);
}
export function disableUnsupportedAlgorithms() {
// TODO: test supported algorithms in runtime
if(p521Supported() === false) {
algorithmEs512.disabled = true;
}
}
export function isString(value) {
return typeof value === 'string' || value instanceof String;
}