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

add trailing slash to amo-base-url & enforce within submit-addon Client #2621

Merged

Conversation

eviljeff
Copy link
Member

fixes #2579

@eviljeff eviljeff requested a review from willdurand January 20, 2023 15:51
@@ -90,6 +90,9 @@ export default class Client {
userAgentString,
}: ClientConstructorParams) {
this.apiAuth = apiAuth;
if (!baseUrl.href.endsWith('/')) {
Copy link
Member

Choose a reason for hiding this comment

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

If the URL somehow contains a ? or # but not a /, then this would not work as desired.

This would fix the issue:

if (!baseUrl.pathname.endsWith('/')) {`
  baseUrl = new URL(baseUrl);
  baseUrl.pathname += "/";
}

P.S. The query and ref will be stripped by new URL('addons/', baseUrl) anyway, so an alternative is to assert that baseUrl.search and baseUrl.hash are both empty.

Copy link
Member Author

Choose a reason for hiding this comment

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

The fix suggestion sounds good. I'm not sure it's worth the extra effort to assert on baseUrl.search and baseUrl.hash though - the code is too specialised to the AMO API here, so trying to support another API that has a different url style is out of scope. (My vote is just to ignore it and let them be stripped)

Copy link
Member Author

Choose a reason for hiding this comment

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

757f47a is your fix(ish)

@eviljeff eviljeff requested a review from willdurand January 23, 2023 22:35
@willdurand
Copy link
Member

@Rob--W if that looks good to you, please merge :) (so that I'll know that you saw both this message and the updated patch)

@willdurand willdurand merged commit 71e19d2 into mozilla:master Jan 24, 2023
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.

--use-submission-api results in HTML response with "Oops! We can’t find that page"
3 participants