Fixes incorrect detection of the username

This commit is contained in:
erwanlr
2015-08-13 10:27:33 +01:00
parent 1652c09e95
commit cc737090a2
2 changed files with 8 additions and 1 deletions

View File

@@ -39,7 +39,7 @@ class WpUser < WpItem
#
# @return [ String ] The login
def self.login_from_author_pattern(text)
return unless text =~ %r{/author/([^/\b]+)/?}i
return unless text =~ %r{/author/([^/\b"']+)/?}i
Regexp.last_match[1].force_encoding('UTF-8')
end

View File

@@ -29,6 +29,13 @@ shared_examples 'WpUser::Existable' do
@expected = nil
end
end
context 'when no author given' do
it 'returns nil' do
@text = '<a href="http://wp.lab/author/" class="btn btn-default">See Posts</a>'
@expected = nil
end
end
end
describe '::login_from_body' do