From cc737090a277d5a19ff1e1e57089abb606849dd2 Mon Sep 17 00:00:00 2001 From: erwanlr Date: Thu, 13 Aug 2015 10:27:33 +0100 Subject: [PATCH] Fixes incorrect detection of the username --- lib/common/models/wp_user/existable.rb | 2 +- spec/shared_examples/wp_user/existable.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/common/models/wp_user/existable.rb b/lib/common/models/wp_user/existable.rb index b4d2c530..03f7137a 100755 --- a/lib/common/models/wp_user/existable.rb +++ b/lib/common/models/wp_user/existable.rb @@ -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 diff --git a/spec/shared_examples/wp_user/existable.rb b/spec/shared_examples/wp_user/existable.rb index ab0e5058..a09557b0 100644 --- a/spec/shared_examples/wp_user/existable.rb +++ b/spec/shared_examples/wp_user/existable.rb @@ -29,6 +29,13 @@ shared_examples 'WpUser::Existable' do @expected = nil end end + + context 'when no author given' do + it 'returns nil' do + @text = 'See Posts' + @expected = nil + end + end end describe '::login_from_body' do