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

Allow for hidden port 80 #128

Merged
merged 1 commit into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/reload-client.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(function refresh () {
var verboseLogging = false
var socketUrl = window.location.origin.replace() // This is dynamically populated by the reload.js file before it is sent to the browser
var socketUrl = window.location.origin
if (!window.location.origin.match(/:[0-9]+/)) {
Copy link
Owner

Choose a reason for hiding this comment

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

We probably want account for port 443 too I'm thinking?

And I'd like this all in a series of if statements.

I'm thinking

if (!window.location.origin.match(/:[0-9]+/)) {

}
else if (https regex for port 443) {

}
else {
  socketUrl = socketUrl.replace() // This is dynamically populated by the reload.js file before it is sent to the browser
}

What are your thoughts on this?

Copy link

Choose a reason for hiding this comment

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

Why does it need to change for port 443?

Copy link
Owner

Choose a reason for hiding this comment

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

Because 443 is also an anonymous port when running https. Might not be relevant though for the command line program?

Copy link

Choose a reason for hiding this comment

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

Seems like a good idea. I'll look into it.

Copy link

Choose a reason for hiding this comment

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

I've made a pull request #129 that does this and has been tested.

Copy link
Owner

Choose a reason for hiding this comment

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

I think this block of code would be safe if it was like:

if (!window.location.origin.match(/:[0-9]+/)) {
  socketUrl = window.location.origin + ':80'
}
else {
  socketUrl = socketUrl.replace() // This is dynamically populated by the reload.js file before it is sent to the browser
}

socketUrl = window.location.origin + ':80'
}
socketUrl = socketUrl.replace() // This is dynamically populated by the reload.js file before it is sent to the browser
var socket

if (verboseLogging) {
Expand Down
2 changes: 1 addition & 1 deletion lib/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = function reload (app, opts, server) {
if (verboseLogging) {
reloadCode = reloadCode.replace('verboseLogging = false', 'verboseLogging = true')
}
reloadCode = reloadCode.replace('window.location.origin.replace()', 'window.location.origin.replace(/(^http(s?):\\/\\/)(.*:)(.*)/,' + (socketPortSpecified ? '\'ws$2://$3' + socketPortSpecified : '\'ws$2://$3$4') + '\')')
reloadCode = reloadCode.replace('socketUrl.replace()', 'socketUrl.replace(/(^http(s?):\\/\\/)(.*:)(.*)/,' + (socketPortSpecified ? '\'ws$2://$3' + socketPortSpecified : '\'ws$2://$3$4') + '\')')

expressApp.get(route, function (req, res) {
res.type('text/javascript')
Expand Down