Skip to content
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

fix(#2281): Prevent double slashes when joining URLs #2282

Merged
merged 5 commits into from Jul 23, 2021

Conversation

woubuc
Copy link
Contributor

@woubuc woubuc commented Jul 22, 2021

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Docs
  • New Binding Issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes. Issue #___
  • No

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

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

Thanks for finding and fixing the bug.
Don't forget to add a change file in .changes folder

core/tauri/src/manager.rs Outdated Show resolved Hide resolved
@woubuc woubuc marked this pull request as draft July 23, 2021 06:47
@woubuc
Copy link
Contributor Author

woubuc commented Jul 23, 2021

  • The custom format!() call has been replaced with the Url.join() function which handles concatenating and normalising URLs a lot better.
    • WindowManager.get_url() now returns a Cow<Url> to make it possible for other functions to use the Url struct directly. I've opted to use Cow to prevent cloning the URL since we just need to read it.
    • The relevant tests in manager.rs have been updated as well to reflect this change.
    • I've also changed the check for external URLs to compare against Url.scheme() instead of converting the entire Url to a string first.
  • A new Error variant InvalidUrl is now used to return parse errors that arise from the url functions (e.g. when trying to load a path with invalid characters).
  • I've also reduced some of the duplicate code in the WindowManager.get_url() functions, the cfg-dependant lines are now a separate function and there is only one match. I think this makes it a bit clearer what happens here. Do let me know if I've misunderstood what the cfg differences are though.

@woubuc woubuc marked this pull request as ready for review July 23, 2021 08:39
@woubuc woubuc requested a review from a team as a code owner July 23, 2021 08:39
Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

core/tauri/src/manager.rs Show resolved Hide resolved
@woubuc
Copy link
Contributor Author

woubuc commented Jul 23, 2021

Looks like I forgot to run Clippy locally before committing.. Should be fixed now.

@lemarier lemarier merged commit 31685c9 into tauri-apps:dev Jul 23, 2021
@lemarier
Copy link
Member

Thanks @woubuc !

We do appreciate a lot your contribution!
Have a great day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants