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

Only replace scheme, host, port, path when translating IPFS URI #7693

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

yrliou
Copy link
Member

@yrliou yrliou commented Jan 25, 2021

This fixes the bug that query parameters and hash anchors were dropped in
TranslateIPFSURI.

Resolves brave/brave-browser#13722

Submitter Checklist:

  • There is a ticket for my issue.
  • Used Github auto-closing keywords in the commit message.
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed).
  • Requested a security/privacy review as needed.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

pre-condition: IPFS local node is started.

  1. Visit ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html#Emerging_artist, it should jump to Emerging artist section.
  2. Open a new tab, and open developer tools's Network tab.
  3. Visit ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/I/m/Vincent_van_Gogh_-Self-Portrait-Google_Art_Project(454045).jpg?filename=test.jpg&download=true, filename=test.jpg&download=true should be kept in the address bar.
  4. Examine the network response using developer tools's Network tab, you should see this Content-Disposition: inline; filename*=UTF-8''test.jpg in the header as below.

Screen Shot 2021-01-25 at 11 26 25 AM

This fixes the bug that query parameters and hash anchors were dropped in
TranslateIPFSURI.
@yrliou
Copy link
Member Author

yrliou commented Jan 25, 2021

pre-init has storybook failure which is unrelated to this PR.


[2021-01-25T18:57:20.146Z] 

[2021-01-25T18:57:20.146Z] ERR! => Failed to build the preview

[2021-01-25T18:57:20.408Z] ERR! /home/ubuntu/workspace/pr-brave-browser-ipfs_keep_query_and_hash_param-pre-init/components/brave_new_tab_ui/stories/default/data/todayStorybookState.ts

[2021-01-25T18:57:20.408Z] ERR! ./components/brave_new_tab_ui/stories/default/data/todayStorybookState.ts

[2021-01-25T18:57:20.408Z] ERR! [tsl] ERROR in /home/ubuntu/workspace/pr-brave-browser-ipfs_keep_query_and_hash_param-pre-init/components/brave_new_tab_ui/stories/default/data/todayStorybookState.ts(149,11)

[2021-01-25T18:57:20.408Z] ERR!       TS2322: Type '{ category: string; publish_time: string; url: string; img: string; title: string; description: string; content_type: "brave_partner"; publisher_id: string; publisher_name: string; url_hash: string; padded_img: string; score: number; points: number; relative_time: string; }' is not assignable to type 'PromotedArticle'.

[2021-01-25T18:57:20.408Z] ERR!   Property 'creative_instance_id' is missing in type '{ category: string; publish_time: string; url: string; img: string; title: string; description: string; content_type: "brave_partner"; publisher_id: string; publisher_name: string; url_hash: string; padded_img: string; score: number; points: number; relative_time: string; }' but required in type '{ content_type: "brave_partner"; creative_instance_id: string; }'.

[2021-01-25T18:57:20.408Z] (node:173435) UnhandledPromiseRejectionWarning: [object Object]

[2021-01-25T18:57:20.408Z] (node:173435) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

[2021-01-25T18:57:20.408Z] (node:173435) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[2021-01-25T18:57:20.408Z] npm ERR! code ELIFECYCLE

[2021-01-25T18:57:20.408Z] npm ERR! errno 1

[2021-01-25T18:57:20.408Z] npm ERR! [email protected] build-storybook: `build-storybook -c .storybook -o .storybook-out`

[2021-01-25T18:57:20.408Z] npm ERR! Exit status 1

[2021-01-25T18:57:20.408Z] npm ERR! 

[2021-01-25T18:57:20.408Z] npm ERR! Failed at the [email protected] build-storybook script.

[2021-01-25T18:57:20.408Z] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@yrliou yrliou merged commit 28463f8 into master Jan 25, 2021
@yrliou yrliou deleted the ipfs_keep_query_and_hash_param branch January 25, 2021 21:49
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.

Bug: ipfs:// drops query and hash parts
2 participants