Skip to content
Browse files

fix TwitterFormHelper::linkify() hashtag url

  • Loading branch information...
1 parent 4ceb62c commit 30762452b1a2f83a5061f6c9a7c748c491666f02 @nojimage nojimage committed Jul 7, 2010
Showing with 7 additions and 7 deletions.
  1. +6 −6 tests/cases/helpers/twitter_form.test.php
  2. +1 −1 views/helpers/twitter_form.php
View
12 tests/cases/helpers/twitter_form.test.php
@@ -31,7 +31,7 @@ function testLinkify()
$this->assertEqual($this->TwitterForm->linkify($value, array('username' => false)), $value);
$value = '#hashtag';
- $result = '<a href="http://search.twitter.com/search?q=#hashtag">#hashtag</a>';
+ $result = '<a href="http://search.twitter.com/search?q=hashtag">#hashtag</a>';
$this->assertEqual($this->TwitterForm->linkify($value), $result);
$this->assertEqual($this->TwitterForm->linkify($value, array('hashtag' => false)), $value);
@@ -41,19 +41,19 @@ function testLinkify()
$this->assertEqual($this->TwitterForm->linkify($value, array('url' => false)), $value);
$value = '@username #hashtag';
- $result = '<a href="http://twitter.com/username">@username</a> <a href="http://search.twitter.com/search?q=#hashtag">#hashtag</a>';
+ $result = '<a href="http://twitter.com/username">@username</a> <a href="http://search.twitter.com/search?q=hashtag">#hashtag</a>';
$this->assertEqual($this->TwitterForm->linkify($value), $result);
$value = '@username#hashtag';
- $result = '<a href="http://twitter.com/username">@username</a><a href="http://search.twitter.com/search?q=#hashtag">#hashtag</a>';
+ $result = '<a href="http://twitter.com/username">@username</a><a href="http://search.twitter.com/search?q=hashtag">#hashtag</a>';
$this->assertEqual($this->TwitterForm->linkify($value), $result);
$value = '@username http://example.com';
$result = '<a href="http://twitter.com/username">@username</a> <a href="http://example.com">http://example.com</a>';
$this->assertEqual($this->TwitterForm->linkify($value), $result);
$value = 'http://example.com #hashtag';
- $result = '<a href="http://example.com">http://example.com</a> <a href="http://search.twitter.com/search?q=#hashtag">#hashtag</a>';
+ $result = '<a href="http://example.com">http://example.com</a> <a href="http://search.twitter.com/search?q=hashtag">#hashtag</a>';
$this->assertEqual($this->TwitterForm->linkify($value), $result);
$value = 'http://example.com/#hashtag';
@@ -65,7 +65,7 @@ function testLinkify()
$this->assertEqual($this->TwitterForm->linkify($value), $result);
$value = '#hash_tag';
- $result = '<a href="http://search.twitter.com/search?q=#hash_tag">#hash_tag</a>';
+ $result = '<a href="http://search.twitter.com/search?q=hash_tag">#hash_tag</a>';
$this->assertEqual($this->TwitterForm->linkify($value), $result);
$value = '@user%name';
@@ -89,7 +89,7 @@ function testLinkify()
$this->assertEqual($this->TwitterForm->linkify($value), $result);
$value = '#hashtag #taghash';
- $result = '<a href="http://search.twitter.com/search?q=#hashtag">#hashtag</a> <a href="http://search.twitter.com/search?q=#taghash">#taghash</a>';
+ $result = '<a href="http://search.twitter.com/search?q=hashtag">#hashtag</a> <a href="http://search.twitter.com/search?q=taghash">#taghash</a>';
$this->assertEqual($this->TwitterForm->linkify($value), $result);
}
View
2 views/helpers/twitter_form.php
@@ -160,7 +160,7 @@ public function linkify($value, $options = array()) {
$replaces = array(
'url' => array('!(^|[\W])(' . $_urlMatch . ')([\W]|$)!iu' => '$1<a href="$2">$2</a>$3'),
'username' => array('!(^|[^\w/?&;])@(\w+)!iu' => '$1<a href="http://twitter.com/$2">@$2</a>$3'),
- 'hashtag' => array('!(^|[^\w/?&;])#(\w+)!iu' => '$1<a href="http://search.twitter.com/search?q=#$2">#$2</a>$3'),
+ 'hashtag' => array('!(^|[^\w/?&;])#(\w+)!iu' => '$1<a href="http://search.twitter.com/search?q=$2">#$2</a>$3'),
);
$options = am($default, $options);

0 comments on commit 3076245

Please sign in to comment.
Something went wrong with that request. Please try again.