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: don't duplicate path in URL to post on subdirectory installs. #3354

Merged
merged 1 commit into from
Apr 23, 2022

Conversation

askvortsov1
Copy link
Sponsor Member

No description provided.

@luceos
Copy link
Member

luceos commented Mar 23, 2022

Feels like this issue solves one instance of a problem, a problem that can cascade into other areas including 3rd party extensions. What is exactly the cause? Is baseUrl sometimes the domain + path and sometimes just the path?

@dsevillamartin
Copy link
Member

@luceos baseUrl has the URL in config.php, so it will always have the subfolder if there is one. app.route will return an URL with the subfolder as well because it is needed for navigation to the correct page (/subfolder/d/...).

return app.forum.attribute('baseUrl') + app.route.post(post);
// URL.hostname transformation is necessary to avoid duplicating
// path in subdirectory installs.
return URL(app.forum.attribute('baseUrl')).hostname + app.route.post(post);
Copy link
Member

Choose a reason for hiding this comment

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

This will not keep URLs which contain ports, nor the protocol. We should use .origin instead.

Suggested change
return URL(app.forum.attribute('baseUrl')).hostname + app.route.post(post);
return new URL(app.forum.attribute('baseUrl')).origin + app.route.post(post);

Base automatically changed from as/typing-fixes to main March 23, 2022 15:43
`baseUrl` includes the path portion of the url, as does `basePath`, which is included in `app.route.x` function outputs. The `baseOrigin` (with no path component at all) should be used instead.
@askvortsov1 askvortsov1 merged commit 863a8dd into main Apr 23, 2022
@askvortsov1 askvortsov1 deleted the as/fix-subdir-post-url branch April 23, 2022 14:23
@askvortsov1 askvortsov1 added this to the 1.3 milestone Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants