You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hunjianghu/江可飞/小程序开发/html-view/each/resolveUrl.js

11 lines
371 B

const { resolve } = require('../vendors/url')
module.exports = baseUrl =>
item => {
if (['img', 'video', 'audio', 'source'].indexOf(item.tagName) !== -1) {
if (item.attributes.src) item.attributes.src = resolve(baseUrl, item.attributes.src)
} else if (item.tagName === 'a') {
item.attributes.href = resolve(baseUrl, item.attributes.href)
}
}