mirror of
https://github.com/nkanaev/yarr.git
synced 2025-09-13 18:00:05 +00:00
cleanup
This commit is contained in:
@@ -26,28 +26,6 @@ var debounce = function(callback, wait) {
|
||||
}
|
||||
}
|
||||
|
||||
var sanitize = function(content, base) {
|
||||
// WILD: `item.link` may be a relative link (or some nonsense)
|
||||
try { new URL(base) } catch(err) { base = null }
|
||||
|
||||
var sanitizer = new DOMPurify
|
||||
sanitizer.addHook('afterSanitizeAttributes', function(node) {
|
||||
// set all elements owning target to target=_blank
|
||||
if ('target' in node)
|
||||
node.setAttribute('target', '_blank')
|
||||
// set non-HTML/MathML links to xlink:show=new
|
||||
if (!node.hasAttribute('target') && (node.hasAttribute('xlink:href') || node.hasAttribute('href')))
|
||||
node.setAttribute('xlink:show', 'new')
|
||||
|
||||
// set absolute urls
|
||||
if (base && node.attributes.href && node.attributes.href.value)
|
||||
node.href = new URL(node.attributes.href.value, base).toString()
|
||||
if (base && node.attributes.src && node.attributes.src.value)
|
||||
node.src = new URL(node.attributes.src.value, base).toString()
|
||||
})
|
||||
return sanitizer.sanitize(content, {FORBID_TAGS: ['style'], FORBID_ATTR: ['style', 'class']})
|
||||
}
|
||||
|
||||
Vue.use(VueLazyload)
|
||||
|
||||
Vue.directive('scroll', {
|
||||
|
Reference in New Issue
Block a user