bibliogram/src/lib/utils/proxyurl.js

19 lines
471 B
JavaScript
Raw Normal View History

2020-01-18 15:38:14 +00:00
function proxyImage(url, width) {
2020-01-14 14:38:33 +00:00
const params = new URLSearchParams()
2020-01-18 15:38:14 +00:00
if (width) params.set("width", width)
2020-01-14 14:38:33 +00:00
params.set("url", url)
return "/imageproxy?"+params.toString()
}
/**
* @param {import("../types").ExtendedOwner} owner
*/
function proxyExtendedOwner(owner) {
const clone = {...owner}
clone.profile_pic_url = proxyImage(clone.profile_pic_url)
return clone
}
2020-01-14 14:38:33 +00:00
module.exports.proxyImage = proxyImage
module.exports.proxyExtendedOwner = proxyExtendedOwner