fix: preserve homeserver port when creating thumbnail URIs
This commit is contained in:
parent
cd5131daa5
commit
44b7c96d73
|
|
@ -46,6 +46,7 @@ extension MxcUriExtension on Uri {
|
||||||
scheme: matrix.homeserver.scheme,
|
scheme: matrix.homeserver.scheme,
|
||||||
host: matrix.homeserver.host,
|
host: matrix.homeserver.host,
|
||||||
path: '/_matrix/media/r0/thumbnail/$host$path',
|
path: '/_matrix/media/r0/thumbnail/$host$path',
|
||||||
|
port: matrix.homeserver.port,
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
if (width != null) 'width': width.round().toString(),
|
if (width != null) 'width': width.round().toString(),
|
||||||
if (height != null) 'height': height.round().toString(),
|
if (height != null) 'height': height.round().toString(),
|
||||||
|
|
|
||||||
|
|
@ -50,5 +50,28 @@ void main() {
|
||||||
.toString(),
|
.toString(),
|
||||||
'${client.homeserver.toString()}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale&animated=true');
|
'${client.homeserver.toString()}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale&animated=true');
|
||||||
});
|
});
|
||||||
|
test('other port', () async {
|
||||||
|
final client = Client('testclient', httpClient: FakeMatrixApi());
|
||||||
|
await client.checkHomeserver('https://fakeserver.notexisting',
|
||||||
|
checkWellKnown: false);
|
||||||
|
client.homeserver = Uri.parse('https://fakeserver.notexisting:1337');
|
||||||
|
final mxc = 'mxc://exampleserver.abc/abcdefghijklmn';
|
||||||
|
final content = Uri.parse(mxc);
|
||||||
|
expect(content.isScheme('mxc'), true);
|
||||||
|
|
||||||
|
expect(content.getDownloadLink(client).toString(),
|
||||||
|
'${client.homeserver.toString()}/_matrix/media/r0/download/exampleserver.abc/abcdefghijklmn');
|
||||||
|
expect(content.getThumbnail(client, width: 50, height: 50).toString(),
|
||||||
|
'${client.homeserver.toString()}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=crop&animated=false');
|
||||||
|
expect(
|
||||||
|
content
|
||||||
|
.getThumbnail(client,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
method: ThumbnailMethod.scale,
|
||||||
|
animated: true)
|
||||||
|
.toString(),
|
||||||
|
'https://fakeserver.notexisting:1337/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale&animated=true');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue