2021-05-20 19:11:58 +00:00
|
|
|
export function ensureProtocol (value) {
|
2021-05-21 19:34:40 +00:00
|
|
|
if (!/^([a-z0-9]+:\/\/|mailto:)/.test(value)) {
|
2021-05-20 19:11:58 +00:00
|
|
|
value = 'http://' + value
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
}
|
2022-11-15 23:51:00 +00:00
|
|
|
|
|
|
|
export function removeTracking (value) {
|
|
|
|
const exprs = [
|
|
|
|
// twitter URLs
|
|
|
|
/^(?<url>https?:\/\/twitter\.com\/(?:#!\/)?(?<user>\w+)\/status(?:es)?\/(?<id>\d+))/,
|
|
|
|
]
|
|
|
|
for (const expr of exprs) {
|
|
|
|
value = expr.exec(value)?.groups.url ?? value;
|
|
|
|
}
|
|
|
|
return value
|
|
|
|
}
|