Carbon/src/js/functions.js

14 lines
432 B
JavaScript
Raw Normal View History

2020-10-23 14:15:14 +00:00
const lsm = require("./lsm.js")
2020-10-19 13:05:16 +00:00
function resolveMxc(url, size, method) {
let [server, id] = url.match(/^mxc:\/\/([^/]+)\/(.*)/).slice(1)
id = id.replace(/#.*$/, "")
2020-10-19 13:05:16 +00:00
if (size && method) {
return `${lsm.get("domain")}/_matrix/media/r0/thumbnail/${server}/${id}?width=${size}&height=${size}&method=${method}`
} else {
return `${lsm.get("domain")}/_matrix/media/r0/download/${server}/${id}`
}
}
2020-10-23 14:15:14 +00:00
module.exports = {resolveMxc}