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

Webfinger resource to extract username from resource string #1607

Merged
merged 2 commits into from
Apr 12, 2017

Conversation

mjankowski
Copy link
Contributor

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!


def username
case resource
when /https/
Copy link
Member

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?/

Copy link
Contributor Author

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

?

Copy link
Member

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

Copy link
Contributor Author

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.

case resource
when /\Ahttps?/i
username_from_url
when /acct/
Copy link
Member

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.

Copy link
Member

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

@mjankowski mjankowski force-pushed the webfinger-resource branch 2 times, most recently from c688e00 to b130e70 Compare April 12, 2017 15:08
case resource
when /\Ahttps?/i
username_from_url
when /acct/
Copy link
Member

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

@mjankowski
Copy link
Contributor Author

Updated to handle the simple user@host (w/out acct:) as well.

@Gargron Gargron merged commit aa90798 into mastodon:master Apr 12, 2017
@mjankowski mjankowski deleted the webfinger-resource branch April 12, 2017 17:29
Gargron added a commit that referenced this pull request Apr 12, 2017
Gargron added a commit that referenced this pull request Apr 13, 2017
thurloat pushed a commit to Moosetodon/mastodon that referenced this pull request Apr 13, 2017
…#1607)

* Add WebfingerResource class to extract usernames

* Use WebfingerResource in xrd#webfinger
thurloat pushed a commit to Moosetodon/mastodon that referenced this pull request Apr 13, 2017
Nyoho referenced this pull request in Nyoho/mathtodon Apr 25, 2017
* Add WebfingerResource class to extract usernames

* Use WebfingerResource in xrd#webfinger
Nyoho referenced this pull request in Nyoho/mathtodon Apr 25, 2017
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