mirror of https://github.com/thumbsup/thumbsup
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
500 B
JavaScript
15 lines
500 B
JavaScript
const path = require('node:path')
|
|
|
|
module.exports = (target, options) => {
|
|
// if already an absolute URL, do nothing
|
|
if (target.match(/^(http|https|file):\/\//)) {
|
|
return target
|
|
}
|
|
const albumPath = options.data.root.album.path
|
|
const backToGalleryRoot = path.relative(path.dirname(albumPath), '.')
|
|
const relative = path.join(backToGalleryRoot, target)
|
|
const url = relative.replace(/\\/g, '/')
|
|
// Escape single/double quotes
|
|
return url.replace(/'/g, '%27').replace(/"/g, '%22')
|
|
}
|