fix: obay explicitly set ports in mxc URLs
This commit is contained in:
parent
63397701b5
commit
5c87b560b9
|
|
@ -24,8 +24,8 @@ extension MxcUriExtension on Uri {
|
||||||
/// Returns a download Link to this content.
|
/// Returns a download Link to this content.
|
||||||
Uri getDownloadLink(Client matrix) => isScheme('mxc')
|
Uri getDownloadLink(Client matrix) => isScheme('mxc')
|
||||||
? matrix.homeserver != null
|
? matrix.homeserver != null
|
||||||
? matrix.homeserver
|
? matrix.homeserver?.resolve(
|
||||||
?.resolve('_matrix/media/r0/download/$host$path') ??
|
'_matrix/media/r0/download/$host${hasPort ? ':$port' : ''}$path') ??
|
||||||
Uri()
|
Uri()
|
||||||
: Uri()
|
: Uri()
|
||||||
: this;
|
: this;
|
||||||
|
|
@ -48,7 +48,7 @@ extension MxcUriExtension on Uri {
|
||||||
return Uri(
|
return Uri(
|
||||||
scheme: homeserver.scheme,
|
scheme: homeserver.scheme,
|
||||||
host: homeserver.host,
|
host: homeserver.host,
|
||||||
path: '/_matrix/media/r0/thumbnail/$host$path',
|
path: '/_matrix/media/r0/thumbnail/$host${hasPort ? ':$port' : ''}$path',
|
||||||
port: homeserver.port,
|
port: homeserver.port,
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
if (width != null) 'width': width.round().toString(),
|
if (width != null) 'width': width.round().toString(),
|
||||||
|
|
|
||||||
|
|
@ -73,5 +73,18 @@ void main() {
|
||||||
.toString(),
|
.toString(),
|
||||||
'https://fakeserver.notexisting:1337/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale&animated=true');
|
'https://fakeserver.notexisting:1337/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale&animated=true');
|
||||||
});
|
});
|
||||||
|
test('other remote port', () async {
|
||||||
|
final client = Client('testclient', httpClient: FakeMatrixApi());
|
||||||
|
await client.checkHomeserver('https://fakeserver.notexisting',
|
||||||
|
checkWellKnown: false);
|
||||||
|
final mxc = 'mxc://exampleserver.abc:1234/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:1234/abcdefghijklmn');
|
||||||
|
expect(content.getThumbnail(client, width: 50, height: 50).toString(),
|
||||||
|
'${client.homeserver.toString()}/_matrix/media/r0/thumbnail/exampleserver.abc:1234/abcdefghijklmn?width=50&height=50&method=crop&animated=false');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue