-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix shared link hostname #5870
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
Fix shared link hostname #5870
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,7 +319,7 @@ defmodule Plausible.SitesTest do | |
|
|
||
| Plausible.Teams.complete_setup(site1.team) | ||
|
|
||
| # excluded | ||
| # excluded | ||
| new_site(owner: user1, domain: "consolidated.example.com", consolidated: true) | ||
|
|
||
| # guest site access | ||
|
|
@@ -373,7 +373,7 @@ defmodule Plausible.SitesTest do | |
| site5 = new_site(domain: "team.example.com", owner: user4) | ||
| add_member(site5.team, user: user1, role: :editor) | ||
|
|
||
| # excluded | ||
| # excluded | ||
| new_site(owner: user1, domain: "consolidated.example.com", consolidated: true) | ||
|
|
||
| assert %{ | ||
|
|
@@ -413,7 +413,7 @@ defmodule Plausible.SitesTest do | |
| team5 = Plausible.Teams.complete_setup(site5.team) | ||
| add_member(site5.team, user: user1, role: :admin) | ||
|
|
||
| # excluded | ||
| # excluded | ||
| new_site(owner: user1, domain: "consolidated.example.com", consolidated: true) | ||
|
|
||
| assert %{ | ||
|
|
@@ -435,7 +435,7 @@ defmodule Plausible.SitesTest do | |
|
|
||
| {:ok, _} = Sites.toggle_pin(pending_owner, site) | ||
|
|
||
| # excluded | ||
| # excluded | ||
| new_site(owner: owner, domain: "consolidated.example.com", consolidated: true) | ||
| new_site(owner: pending_owner, domain: "consolidated2.example.com", consolidated: true) | ||
|
|
||
|
|
@@ -1021,4 +1021,28 @@ defmodule Plausible.SitesTest do | |
| end | ||
| end | ||
| end | ||
|
|
||
| describe "shared_link_url/2" do | ||
| test "contains base URL and slug" do | ||
| site = new_site(domain: "example.com/deep/path") | ||
| link = insert(:shared_link, site: site) | ||
|
|
||
| # base url in tests is http://localhost:8000, in prod, it's https://plausible.io | ||
| assert "http://localhost:8000/share/example.com%2Fdeep%2Fpath?auth=" <> slug = | ||
| Sites.shared_link_url(site, link) | ||
|
|
||
| # we assume slug is URL safe | ||
| assert ^slug = link.slug | ||
| end | ||
|
|
||
| test "doesn't share the same domain formatting with public dashboard links" do | ||
| site = new_site(domain: "a-café.fr") | ||
| link = insert(:shared_link, site: site) | ||
|
|
||
| assert "http://localhost:8000/a-café.fr" = PlausibleWeb.StatsView.pretty_stats_url(site) | ||
|
|
||
| assert "http://localhost:8000/share/a-caf%C3%A9.fr?" <> _q = | ||
| Sites.shared_link_url(site, link) | ||
|
Comment on lines
+1038
to
+1045
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This codifies current non-ideal behavior that I noticed. It's worth thinking about how to unify the two and all our other route utils as well. |
||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has the benefit of ensuring proper encoding even for auth query parameter, which Plausible.Sites.shared_link_url/2 doesn't actually do. We could make use of this same logic in Plausible.Sites.shared_link_url/2, but it didn't make sense to me when I considered the relation between the modules Routes / Plausible.Sites.