-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Webfinger resource to extract username from resource string #1607
Conversation
app/lib/webfinger_resource.rb
Outdated
|
||
def username | ||
case resource | ||
when /https/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking this should be /https?/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I missed that in the original ... so both of these strings should work?
http://example.com/users/name
->name
https://example.com/users/name
->name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although your tests seem to account for the http case so I'm not sure what this regex does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated to reflect that https is supported.
4513dcc
to
c1e2684
Compare
app/lib/webfinger_resource.rb
Outdated
case resource | ||
when /\Ahttps?/i | ||
username_from_url | ||
when /acct/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking right now - You should be able to pass username@domain without the acct: in the front, and it should be able to deal with that. So maybe just make that the else condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have submitted that as a change request - this should be able to handle username@domain
without the acct:
at the front
c688e00
to
b130e70
Compare
app/lib/webfinger_resource.rb
Outdated
case resource | ||
when /\Ahttps?/i | ||
username_from_url | ||
when /acct/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have submitted that as a change request - this should be able to handle username@domain
without the acct:
at the front
9810e1a
to
3296fb6
Compare
3296fb6
to
8ccf68e
Compare
Updated to handle the simple |
…#1607) * Add WebfingerResource class to extract usernames * Use WebfingerResource in xrd#webfinger
* Add WebfingerResource class to extract usernames * Use WebfingerResource in xrd#webfinger
I noticed the logic in this controller contained a reference to
params_path[:controller] == 'users'
which I think must be for outdated code (that route no longer exists?). I extracted the logic to pull out a username from a resource to it's own class, and added specs for the strings I'm guessing this is supposed to handle.Feedback on whether that list of strings is exhaustive and sufficient would be appreciated!