feat(fedi): add mxc regex for media
This commit is contained in:
parent
c1e8a44dd0
commit
cdd4429549
1 changed files with 3 additions and 1 deletions
|
@ -76,8 +76,10 @@ exports.runQuery = async (client, room, userInput, registrar, { isReply, hasMedi
|
||||||
chunks.shift();
|
chunks.shift();
|
||||||
}
|
}
|
||||||
if(hasMedia) {
|
if(hasMedia) {
|
||||||
const url = new URL(chunks[0]);
|
let url = new URL(chunks[0]);
|
||||||
chunks.shift();
|
chunks.shift();
|
||||||
|
if(url.protocol === 'mxc:' && url.hostname && url.pathname)
|
||||||
|
url = new URL(`${registrar.config.matrix.domain}/_matrix/media/r0/download/${url.hostname}${url.pathname}`);
|
||||||
if(url.protocol !== 'https:') throw '';
|
if(url.protocol !== 'https:') throw '';
|
||||||
if(!registrar.config.matrix.domains.includes(url.hostname)) throw '';
|
if(!registrar.config.matrix.domains.includes(url.hostname)) throw '';
|
||||||
if(!/^\/_matrix\/media\/r0\/download\/[^/]+\/[^/]+\/?$/.test(url.pathname)) throw '';
|
if(!/^\/_matrix\/media\/r0\/download\/[^/]+\/[^/]+\/?$/.test(url.pathname)) throw '';
|
||||||
|
|
Loading…
Reference in a new issue