nextcloud / neon

A framework for building convergent cross-platform Nextcloud clients using Flutter.
Other
121 stars 29 forks source link

Use UriTemplates for the Uris #1097

Closed Leptopoda closed 9 months ago

Leptopoda commented 10 months ago

We currently query encode path parameters which is not required by the openapi specification. Only query parameters need to be:

    final x0 = Uri.encodeQueryComponent(x.toString());
    final y0 = Uri.encodeQueryComponent(y.toString());
    [...]
    final file0 = Uri.encodeQueryComponent(file);
    final path = '/index.php/apps/files/api/v1/thumbnail/$x0/$y0/$file0';
    final uri = Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null);

https://swagger.io/docs/specification/serialization/ has a table on how to interpret parameter specifications as an RFC 6570 uri template. The google published dart library uri already supports these templates (https://pub.dev/documentation/uri/latest/uri/UriTemplate-class.html) so switching to them might:

@provokateurin what do you think? Shouldn't be that hard.

provokateurin commented 10 months ago

Oh that sounds very good, I assume it will also already handle the URL encoding for us?

Leptopoda commented 10 months ago

I think this is part of the RFC specification. Let's see

provokateurin commented 10 months ago

@Leptopoda May I take this issue over? You already have so much dynamite work on your plate

Leptopoda commented 10 months ago

sure

provokateurin commented 10 months ago

Later on we should also use the UriTemplates for query parameters.

provokateurin commented 10 months ago

Unassigning myself for now

Leptopoda commented 10 months ago

removing from the milestone as we now no longer incorrectly encode path parameters.

Leptopoda commented 9 months ago

the pr didn't auto close this issue :( closing as done.