1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Don't return non-mxc URLs by default.

This commit is contained in:
David Baker
2015-11-12 11:57:53 +00:00
parent 4f851dc431
commit 7095753410
3 changed files with 27 additions and 10 deletions

View File

@@ -13,14 +13,22 @@ module.exports = {
* @param {Number} height The desired height of the thumbnail.
* @param {string} resizeMethod The thumbnail resize method to use, either
* "crop" or "scale".
* @param {Boolean} allowDirectLinks If true, return any non-mxc URLs
* directly. Fetching such URLs will leak information about the user to
* anyone they share a room with. If false, will return the emptry string
* for such URLs.
* @return {string} The complete URL to the content.
*/
getHttpUriForMxc: function(baseUrl, mxc, width, height, resizeMethod) {
getHttpUriForMxc: function(baseUrl, mxc, width, height, resizeMethod, allowDirectLinks) {
if (typeof mxc !== "string" || !mxc) {
return mxc;
return '';
}
if (mxc.indexOf("mxc://") !== 0) {
return mxc;
if (allowDirectLinks) {
return mxc;
} else {
return '';
}
}
var serverAndMediaId = mxc.slice(6); // strips mxc://
var prefix = "/_matrix/media/v1/download/";