Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fix discrepancy between node url.parse and muon.url.parse #13916

Merged
merged 1 commit into from
May 2, 2018

Conversation

diracdeltas
Copy link
Member

@diracdeltas diracdeltas commented Apr 24, 2018

fix #13906

Test Plan:

  1. npm run test -- --grep='muon tests'

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Test Plan:

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

Test Plan:
1. npm run test -- --grep='muon tests'
@diracdeltas diracdeltas added this to the 0.24.x (Nightly Channel) milestone Apr 24, 2018
@diracdeltas diracdeltas self-assigned this Apr 24, 2018
@diracdeltas diracdeltas requested a review from petemill April 24, 2018 00:28
@@ -365,7 +365,7 @@ module.exports = {
test.strictEqual(urlUtil().getOrigin('https://abc.bing.com'), 'https://abc.bing.com')
},
'gets URL origin for url with port': (test) => {
test.strictEqual(urlUtil().getOrigin('https://bing.com:443/?test=1#abc'), 'https://bing.com:443')
test.strictEqual(urlUtil().getOrigin('https://bing.com:8000/?test=1#abc'), 'https://bing.com:8000')
Copy link
Member Author

@diracdeltas diracdeltas Apr 24, 2018

Choose a reason for hiding this comment

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

this test was failing in muon because muon gets the origin from GURL.GetOrigin (https://cs.chromium.org/chromium/src/url/gurl.h?q=gurl&sq=package:chromium&l=201), which doesn't return the port if it's 443 for HTTPS or 80 for HTTP

@codecov-io
Copy link

codecov-io commented Apr 24, 2018

Codecov Report

Merging #13916 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master   #13916      +/-   ##
==========================================
- Coverage   56.48%   56.48%   -0.01%     
==========================================
  Files         283      283              
  Lines       28993    28992       -1     
  Branches     4812     4812              
==========================================
- Hits        16378    16377       -1     
  Misses      12615    12615
Flag Coverage Δ
#unittest 56.48% <100%> (-0.01%) ⬇️
Impacted Files Coverage Δ
js/lib/urlutil.js 86.78% <100%> (-0.05%) ⬇️

@rvagg
Copy link

rvagg commented Apr 25, 2018

nice 👍

@@ -481,11 +481,12 @@ const UrlUtil = {
// parsed.origin is specific to muon.url.parse
if (parsed.origin !== undefined) {
if (parsed.protocol === 'about:') {
return [parsed.protocol, parsed.path].join('')
return [parsed.protocol, parsed.path.replace(/\/.*/, '')].join('')
Copy link
Member

Choose a reason for hiding this comment

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

Is parsed.path always a string, and never null / undefined? I'm guessing so if the test cases without path are working...

Copy link
Member Author

Choose a reason for hiding this comment

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

@petemill this code only runs for muon.url.parse, where parsed.origin is not undefined. in that case, path is always a string.

@diracdeltas diracdeltas requested a review from NejcZdovc April 30, 2018 19:34
Copy link
Member

@petemill petemill left a comment

Choose a reason for hiding this comment

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

lgtm

@petemill petemill modified the milestones: 0.24.x (Nightly Channel), 0.23.x (Developer Channel) May 2, 2018
@diracdeltas diracdeltas merged commit 4ae26c3 into master May 2, 2018
@diracdeltas
Copy link
Member Author

master / 0.24.x: 4ae26c3

On second thought, I'm going to move this back out of 0.23.x since it depends on other changes to the urlutil tests that are only in 0.24.x

@diracdeltas diracdeltas deleted the fix/13906 branch May 2, 2018 05:00
@diracdeltas diracdeltas modified the milestones: 0.23.x (Developer Channel), 0.24.x (Nightly Channel) May 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

some url tests work for node but not muon
4 participants