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

Exclude default ports 80/443 from base URL #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dinoboff
Copy link
Contributor

@dinoboff dinoboff commented Dec 23, 2017

Fix #59

Breaking changes: the URL is validated

oauth-1.0a.js Outdated
},

// Parse url into components.
parseUrl: {
Copy link
Contributor Author

@dinoboff dinoboff Dec 24, 2017

Choose a reason for hiding this comment

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

I defined the helper as a static method (easier for testing) but I am happy to define it on the prototype like the other helpers if you prefer.

Copy link
Owner

Choose a reason for hiding this comment

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

is static method is supported by older nodejs or browser?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IE9+, Safari 5+ and evergreen browser support Object.defineProperties. I am guessing every node versions support ES 5.1; node 0.10 certainly supports Object.defineProperties.

If you need better support, I can define it as OAuth.parseUrl = function(url) {...}.

Copy link
Owner

Choose a reason for hiding this comment

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

how about prototype?

@ddo
Copy link
Owner

ddo commented Jan 3, 2018

too many changes. take me time to review all of them, be patient

@ddo
Copy link
Owner

ddo commented Jan 3, 2018

this PR only "Exclude default ports 80/443 from base URL"? why take 13 files changes

@dinoboff dinoboff force-pushed the fix/issues/#59-2 branch 2 times, most recently from b25563d to 5b6701d Compare January 3, 2018 13:45
@dinoboff
Copy link
Contributor Author

dinoboff commented Jan 3, 2018

@ddo Rebased on master

@dinoboff
Copy link
Contributor Author

dinoboff commented Jan 6, 2018

@ddo

Define parseUrl(url) with the other helpers.

@dinoboff
Copy link
Contributor Author

dinoboff commented Jan 6, 2018

That's crud fix. Maybe we should parse the URL without reg. exp. It would avoid any breaking changes.

@ddo
Copy link
Owner

ddo commented Jan 22, 2018

i still checking the regex part. any source?

@dinoboff
Copy link
Contributor Author

dinoboff commented Jan 23, 2018

Based on https://en.wikipedia.org/wiki/URL (although I just notice the password part of the auth should be optional). The host is optional but required for OAuth request:

/^
  (https?):\/\/      # scheme://
  ([^:]+:[^@]+@)?    # [user[:password]@] (to fix)
  ([^:/?#]+)         # host
  (\:\d+)?           # [:port]
  (\/[^?#]*)?        # [/path]
  (\?[^#]*)?         # [?query]
  (#.*)?             # [#fragment] 
$/

@ddo
Copy link
Owner

ddo commented Jan 25, 2018

i think we do it too complicated for this simple task?

@dinoboff
Copy link
Contributor Author

Possibly. We don't need to extract the scheme + port and later the query with the same regexp.

var match = this._urlPattern.exec(url);
var components;

if (match == null || match.len < 8) {
Copy link
Owner

Choose a reason for hiding this comment

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

i really don't understand this line. does this check http prefix?

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.

2 participants