style: standard

This commit is contained in:
curben 2019-09-04 03:05:13 +01:00
parent ffd57460c7
commit 3fca979939
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
1 changed files with 9 additions and 7 deletions

View File

@ -13,7 +13,6 @@
const moment = require('moment')
const { escapeHTML, htmlTag, stripHTML } = require('hexo-util')
const micromatch = require('micromatch')
function meta (name, content, escape) {
if (escape !== false && typeof content === 'string') {
@ -67,7 +66,7 @@ function openGraphHelper (options = {}) {
}
if (!images.length && content && content.includes('<img')) {
images = images.slice();
images = images.slice()
let img
const imgPattern = /<img [^>]*src=['"]([^'"]+)([^>]*>)/gi
@ -103,14 +102,17 @@ function openGraphHelper (options = {}) {
}
images = images.map(path => {
// parse relative url to full url
let url
// resolve `path`'s absolute path relative to current page's url
// `path` can be both absolute (starts with `/`) or relative.
try {
new URL(path)
} catch {
return new URL(path, config.url).href
url = new URL(path).href
} catch (e) {
url = new URL(path, config.url).href
return url
}
return path
return url
})
images.forEach(path => {