Skip to content

Conversation

@soyuka
Copy link
Contributor

@soyuka soyuka commented Apr 25, 2018

No description provided.

@soyuka soyuka requested review from bcomnes and e-e-e April 25, 2018 13:16
@coveralls
Copy link

coveralls commented Apr 25, 2018

Pull Request Test Coverage Report for Build 71

  • 19 of 19 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+3.7%) to 84.828%

Totals Coverage Status
Change from base Build 68: 3.7%
Covered Lines: 74
Relevant Lines: 79

💛 - Coveralls
Copy link
Member

@e-e-e e-e-e left a comment

Choose a reason for hiding this comment

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

@soyuka thanks for the PR. This is great. I just have a few tiny comments.

stopServer(t)
t.doesNotThrow(ra.write.bind(ra, 10, 'some-data', function () {
stopServer(t)
}))
Copy link
Member

Choose a reason for hiding this comment

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

nice catch.

})

test('parseUrl assumes http with path', (t) => {
t.same(parseUrl('example.com/foo/bar.html'), 'http://example.com/foo/bar.html')
Copy link
Member

Choose a reason for hiding this comment

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

should we assume https:// by default? Perhaps open another issue to enable falling back to http. This will ensure more secure connections are preferred always.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What happens if the certificate is not valid? A correct server implementation will redirect http to https when available IMO.

lib/url.js Outdated
return ['http:', 'https:'].includes(parsed.protocol)
}

module.exports.parseUrl = function (str) {
Copy link
Member

Choose a reason for hiding this comment

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

This is not really a parse function, so the name is slightly misleading. Perhaps appendUrlProtocol is a more descriptive name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replaced by prependUrlProtocol

lib/url.js Outdated
module.exports.validUrl = function (str) {
if (typeof str !== 'string') return false
var parsed = url.parse(str)
return ['http:', 'https:'].includes(parsed.protocol)
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth using regex for this check, just to avoid needing to use polyfills for this to work in IE.

@e-e-e
Copy link
Member

e-e-e commented Apr 26, 2018

Thanks again. This looks great. We can maybe add an option later to prefer https or http as default.
@bcomnes anything to add before I merge?

@soyuka
Copy link
Contributor Author

soyuka commented Apr 26, 2018

Thanks again. This looks great. We can maybe add an option later to prefer https or http as default.

In this case user should just add the protocol :D.

@e-e-e
Copy link
Member

e-e-e commented Apr 26, 2018

In this case user should just add the protocol :D.

😆 You are too right.

@soyuka soyuka merged commit 14d34cb into random-access-storage:master Apr 26, 2018
@soyuka soyuka deleted the fix-1 branch April 26, 2018 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants