Skip to content

fix(share_plus): Fix url encoding for web, Linux and Windows #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 14, 2021

Conversation

ueman
Copy link
Contributor

@ueman ueman commented May 13, 2021

Description

This fixes the issue mentiond in #235

Are there any existing unit tests which I can add a test to?

Related Issues

Fixes #235
Fixes #226 (at least a part of it)

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@miquelbeltran
Copy link
Member

awesome! thanks a lot.

Are there any existing unit tests which I can add a test to?

have you tried to run the e2e "integration" tests present in the main project (share_plus) on these two platforms?

@ueman
Copy link
Contributor Author

ueman commented May 13, 2021

have you tried to run the e2e "integration" tests present in the main project (share_plus) on these two platforms?

Only Web seems to have integration tests.

My idea would be to add a unit test project for each platform project.
Then I can stub the MethodChannel of the launch package and make sure that each call is correctly encoded.
Do I need to add the new test suits to any file or does it work automagically?

I also just noticed that Windows has the same problem, so I fixed that too.

@ueman ueman changed the title Fix url encoding for web and Linux in share plugin Fix url encoding for web, Linux and Windows in share plugin May 13, 2021
@miquelbeltran
Copy link
Member

miquelbeltran commented May 14, 2021

Only Web seems to have integration tests.

The integration tests are on share_plus on purpose and execute from the example folder, they are platform agnostic. Please read the CONTRIBUTING.md document is explained there. When you run the test, you select which platform you want it to run.

(another different thing is if they work or not but that's how this project is structured)

My idea would be to add a unit test project for each platform project.
Then I can stub the MethodChannel of the launch package and make sure that each call is correctly encoded.

That would be nice, yes!

@ueman ueman changed the title Fix url encoding for web, Linux and Windows in share plugin fix(share_plus): Fix url encoding for web, Linux and Windows May 14, 2021
@ueman ueman marked this pull request as ready for review May 14, 2021 07:31
Copy link
Member

@miquelbeltran miquelbeltran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, thanks a lot!

I will merge it and release new version for share_plus_{web, linux, windows}


final uri = Uri(
scheme: 'mailto',
queryParameters: queryParameters,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is actually wrong due to a Dart bug (which is why I didn't suggest this format when I filed the issue). See dart-lang/sdk#43838, especially dart-lang/sdk#43838 (comment).

This will fix the issue I filed, but may cause spaces to be converted to + depending on the handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unfortunate 😅 Are there more gotchas which I should be aware of before attempting another fix?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None that I know of, no. I would suggest including spaces in the values in your unit tests on the next round, so that tests will prevent someone accidentally falling into this trap again in the future when maintaining these plugins (although hopefully the issue will be fixed in Dart itself at some point).

@miquelbeltran
Copy link
Member

after fixing the merge issues I saw that the tests aren't passing, I will leave that to you @ueman :) once it is fix I will release the packages and merge

@miquelbeltran
Copy link
Member

thanks for the fix! I don't know why CI is canceling the job all the time, will investigate :/

@miquelbeltran miquelbeltran merged commit 585846f into fluttercommunity:main May 14, 2021
@miquelbeltran
Copy link
Member

packages has been published

@ueman ueman deleted the fix/url-encoding branch May 14, 2021 16:54
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants