fix: Return empty uri instead of original uri if uri is not mxc
This commit is contained in:
parent
7ade99292b
commit
f0ab627031
|
|
@ -28,7 +28,7 @@ extension MxcUriExtension on Uri {
|
|||
'_matrix/media/v3/download/$host${hasPort ? ':$port' : ''}$path') ??
|
||||
Uri()
|
||||
: Uri()
|
||||
: this;
|
||||
: Uri();
|
||||
|
||||
/// Returns a scaled thumbnail link to this content with the given `width` and
|
||||
/// `height`. `method` can be `ThumbnailMethod.crop` or
|
||||
|
|
@ -40,7 +40,7 @@ extension MxcUriExtension on Uri {
|
|||
num? height,
|
||||
ThumbnailMethod? method = ThumbnailMethod.crop,
|
||||
bool? animated = false}) {
|
||||
if (!isScheme('mxc')) return this;
|
||||
if (!isScheme('mxc')) return Uri();
|
||||
final homeserver = matrix.homeserver;
|
||||
if (homeserver == null) {
|
||||
return Uri();
|
||||
|
|
|
|||
|
|
@ -82,5 +82,13 @@ void main() {
|
|||
expect(content.getThumbnail(client, width: 50, height: 50).toString(),
|
||||
'${client.homeserver.toString()}/_matrix/media/v3/thumbnail/exampleserver.abc:1234/abcdefghijklmn?width=50&height=50&method=crop&animated=false');
|
||||
});
|
||||
test('Wrong scheme returns empty object', () async {
|
||||
final client = Client('testclient', httpClient: FakeMatrixApi());
|
||||
await client.checkHomeserver(Uri.parse('https://fakeserver.notexisting'),
|
||||
checkWellKnown: false);
|
||||
final mxc = Uri.parse('https://wrong-scheme.com');
|
||||
expect(mxc.getDownloadLink(client).toString(), '');
|
||||
expect(mxc.getThumbnail(client).toString(), '');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue