Merge branch 'soru/fix-mxc-port' into 'main'
fix: obay explicitly set ports in mxc URLs Closes famedly/fluffychat#620 See merge request famedly/company/frontend/famedlysdk!861
This commit is contained in:
commit
5b5c110833
|
|
@ -24,8 +24,8 @@ extension MxcUriExtension on Uri {
|
|||
/// Returns a download Link to this content.
|
||||
Uri getDownloadLink(Client matrix) => isScheme('mxc')
|
||||
? matrix.homeserver != null
|
||||
? matrix.homeserver
|
||||
?.resolve('_matrix/media/r0/download/$host$path') ??
|
||||
? matrix.homeserver?.resolve(
|
||||
'_matrix/media/r0/download/$host${hasPort ? ':$port' : ''}$path') ??
|
||||
Uri()
|
||||
: Uri()
|
||||
: this;
|
||||
|
|
@ -48,7 +48,7 @@ extension MxcUriExtension on Uri {
|
|||
return Uri(
|
||||
scheme: homeserver.scheme,
|
||||
host: homeserver.host,
|
||||
path: '/_matrix/media/r0/thumbnail/$host$path',
|
||||
path: '/_matrix/media/r0/thumbnail/$host${hasPort ? ':$port' : ''}$path',
|
||||
port: homeserver.port,
|
||||
queryParameters: {
|
||||
if (width != null) 'width': width.round().toString(),
|
||||
|
|
|
|||
|
|
@ -73,5 +73,18 @@ void main() {
|
|||
.toString(),
|
||||
'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