mirror of
https://github.com/nexus-stc/hyperboria
synced 2024-12-22 17:47:45 +01:00
d51e5ab65d
- fix: Translation fixes - fix: Various fixes - feat: PB translations, configuration changes - fix: Bugfixes GitOrigin-RevId: 55f8b148c42a296162fc707c36a5146ca0073b4b
33 lines
863 B
JavaScript
33 lines
863 B
JavaScript
const ALNUMWHITESPACE_REGEX = /\P{L}/gu
|
|
const MULTIWHITESPACE_REGEX = /\s+/g
|
|
|
|
export function castStringToSingleString (s) {
|
|
let processed = s.replace(ALNUMWHITESPACE_REGEX, ' ')
|
|
processed = processed.replace(MULTIWHITESPACE_REGEX, '-')
|
|
return processed
|
|
}
|
|
|
|
export function escapeFormat (text) {
|
|
return text.replace(/_+/g, '_')
|
|
.replace(/\*+/g, '*')
|
|
.replace(/`+/g, "'")
|
|
.replace(/\[+/g, '`[`')
|
|
.replace(/]+/g, '`]`')
|
|
}
|
|
|
|
export function quoteUrl (url, safe) {
|
|
if (typeof (safe) !== 'string') {
|
|
safe = '/'
|
|
}
|
|
url = encodeURIComponent(url)
|
|
const toUnencode = []
|
|
for (let i = safe.length - 1; i >= 0; --i) {
|
|
const encoded = encodeURIComponent(safe[i])
|
|
if (encoded !== safe.charAt(i)) {
|
|
toUnencode.push(encoded)
|
|
}
|
|
}
|
|
url = url.replace(new RegExp(toUnencode.join('|'), 'ig'), decodeURIComponent)
|
|
return url
|
|
}
|