]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/bookmark/LinkUtilsTest.php
3 namespace Shaarli\Bookmark
;
7 require_once 'tests/utils/CurlUtils.php';
10 * Class LinkUtilsTest.
12 class LinkUtilsTest
extends TestCase
15 * Test html_extract_title() when the title is found.
17 public function testHtmlExtractExistentTitle()
19 $title = 'Read me please.';
20 $html = '<html><meta>stuff</meta><title>' . $title . '</title></html>';
21 $this->assertEquals($title, html_extract_title($html));
22 $html = '<html><title>' . $title . '</title>blabla<title>another</title></html>';
23 $this->assertEquals($title, html_extract_title($html));
27 * Test html_extract_title() when the title is not found.
29 public function testHtmlExtractNonExistentTitle()
31 $html = '<html><meta>stuff</meta></html>';
32 $this->assertFalse(html_extract_title($html));
36 * Test headers_extract_charset() when the charset is found.
38 public function testHeadersExtractExistentCharset()
40 $charset = 'x-MacCroatian';
41 $headers = 'text/html; charset=' . $charset;
42 $this->assertEquals(strtolower($charset), header_extract_charset($headers));
46 * Test headers_extract_charset() when the charset is found with odd quotes.
48 public function testHeadersExtractExistentCharsetWithQuotes()
50 $charset = 'x-MacCroatian';
51 $headers = 'text/html; charset="' . $charset . '"otherstuff="test"';
52 $this->assertEquals(strtolower($charset), header_extract_charset($headers));
54 $headers = 'text/html; charset=\'' . $charset . '\'otherstuff="test"';
55 $this->assertEquals(strtolower($charset), header_extract_charset($headers));
59 * Test headers_extract_charset() when the charset is not found.
61 public function testHeadersExtractNonExistentCharset()
64 $this->assertFalse(header_extract_charset($headers));
66 $headers = 'text/html';
67 $this->assertFalse(header_extract_charset($headers));
71 * Test html_extract_charset() when the charset is found.
73 public function testHtmlExtractExistentCharset()
75 $charset = 'x-MacCroatian';
76 $html = '<html><meta>stuff2</meta><meta charset="' . $charset . '"/></html>';
77 $this->assertEquals(strtolower($charset), html_extract_charset($html));
81 * Test html_extract_charset() when the charset is not found.
83 public function testHtmlExtractNonExistentCharset()
85 $html = '<html><meta>stuff</meta></html>';
86 $this->assertFalse(html_extract_charset($html));
87 $html = '<html><meta>stuff</meta><meta charset=""/></html>';
88 $this->assertFalse(html_extract_charset($html));
92 * Test html_extract_tag() when the tag <meta name= is found.
94 public function testHtmlExtractExistentNameTag()
96 $description = 'Bob and Alice share cookies.';
99 $html = '<html><meta>stuff2</meta><meta name="description" content="' . $description . '"/></html>';
100 $this->assertEquals($description, html_extract_tag('description', $html));
103 $html = '<meta property="og:description" content="' . $description . '">';
104 $this->assertEquals($description, html_extract_tag('description', $html));
106 // Simple reversed OpenGraph
107 $html = '<meta content="' . $description . '" property="og:description">';
108 $this->assertEquals($description, html_extract_tag('description', $html));
110 // ItemProp OpenGraph
111 $html = '<meta itemprop="og:description" content="' . $description . '">';
112 $this->assertEquals($description, html_extract_tag('description', $html));
114 // OpenGraph without quotes
115 $html = '<meta property=og:description content="' . $description . '">';
116 $this->assertEquals($description, html_extract_tag('description', $html));
118 // OpenGraph reversed without quotes
119 $html = '<meta content="' . $description . '" property=og:description>';
120 $this->assertEquals($description, html_extract_tag('description', $html));
122 // OpenGraph with noise
123 $html = '<meta tag1="content1" property="og:description" tag2="content2" content="' .
124 $description . '" tag3="content3">';
125 $this->assertEquals($description, html_extract_tag('description', $html));
127 // OpenGraph reversed with noise
128 $html = '<meta tag1="content1" content="' . $description . '" ' .
129 'tag3="content3" tag2="content2" property="og:description">';
130 $this->assertEquals($description, html_extract_tag('description', $html));
132 // OpenGraph multiple properties start
133 $html = '<meta property="unrelated og:description" content="' . $description . '">';
134 $this->assertEquals($description, html_extract_tag('description', $html));
136 // OpenGraph multiple properties end
137 $html = '<meta property="og:description unrelated" content="' . $description . '">';
138 $this->assertEquals($description, html_extract_tag('description', $html));
140 // OpenGraph multiple properties both end
141 $html = '<meta property="og:unrelated1 og:description og:unrelated2" content="' . $description . '">';
142 $this->assertEquals($description, html_extract_tag('description', $html));
144 // OpenGraph multiple properties both end with noise
145 $html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" '.
146 'tag2="content2" content="' . $description . '" tag3="content3">';
147 $this->assertEquals($description, html_extract_tag('description', $html));
149 // OpenGraph reversed multiple properties start
150 $html = '<meta content="' . $description . '" property="unrelated og:description">';
151 $this->assertEquals($description, html_extract_tag('description', $html));
153 // OpenGraph reversed multiple properties end
154 $html = '<meta content="' . $description . '" property="og:description unrelated">';
155 $this->assertEquals($description, html_extract_tag('description', $html));
157 // OpenGraph reversed multiple properties both end
158 $html = '<meta content="' . $description . '" property="og:unrelated1 og:description og:unrelated2">';
159 $this->assertEquals($description, html_extract_tag('description', $html));
161 // OpenGraph reversed multiple properties both end with noise
162 $html = '<meta tag1="content1" content="' . $description . '" tag2="content2" '.
163 'property="og:unrelated1 og:description og:unrelated2" tag3="content3">';
164 $this->assertEquals($description, html_extract_tag('description', $html));
166 // Suggestion from #1375
167 $html = '<meta property="og:description" name="description" content="' . $description . '">';
168 $this->assertEquals($description, html_extract_tag('description', $html));
172 * Test html_extract_tag() with double quoted content containing single quote, and the opposite.
174 public function testHtmlExtractExistentNameTagWithMixedQuotes(): void
176 $description = 'Bob and Alice share M&M\'s.';
178 $html = '<meta property="og:description" content="' . $description . '">';
179 $this->assertEquals($description, html_extract_tag('description', $html));
181 $html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" '.
182 'tag2="content2" content="' . $description . '" tag3="content3">';
183 $this->assertEquals($description, html_extract_tag('description', $html));
185 $html = '<meta property="og:description" name="description" content="' . $description . '">';
186 $this->assertEquals($description, html_extract_tag('description', $html));
188 $description = 'Bob and Alice share "cookies".';
190 $html = '<meta property="og:description" content=\'' . $description . '\'>';
191 $this->assertEquals($description, html_extract_tag('description', $html));
193 $html = '<meta tag1="content1" property="og:unrelated1 og:description og:unrelated2" '.
194 'tag2="content2" content=\'' . $description . '\' tag3="content3">';
195 $this->assertEquals($description, html_extract_tag('description', $html));
197 $html = '<meta property="og:description" name="description" content=\'' . $description . '\'>';
198 $this->assertEquals($description, html_extract_tag('description', $html));
202 * Test html_extract_tag() when the tag <meta name= is not found.
204 public function testHtmlExtractNonExistentNameTag()
206 $html = '<html><meta>stuff2</meta><meta name="image" content="img"/></html>';
207 $this->assertFalse(html_extract_tag('description', $html));
210 $html = '<meta content="Brief description">';
211 $this->assertFalse(html_extract_tag('description', $html));
213 $html = '<meta property="og:description">';
214 $this->assertFalse(html_extract_tag('description', $html));
216 $html = '<meta tag1="content1" property="og:description">';
217 $this->assertFalse(html_extract_tag('description', $html));
219 $html = '<meta property="og:description" tag1="content1">';
220 $this->assertFalse(html_extract_tag('description', $html));
222 $html = '<meta tag1="content1" content="Brief description">';
223 $this->assertFalse(html_extract_tag('description', $html));
225 $html = '<meta content="Brief description" tag1="content1">';
226 $this->assertFalse(html_extract_tag('description', $html));
230 * Test html_extract_tag() when the tag <meta property="og: is found.
232 public function testHtmlExtractExistentOgTag()
234 $description = 'Bob and Alice share cookies.';
235 $html = '<html><meta>stuff2</meta><meta property="og:description" content="' . $description . '"/></html>';
236 $this->assertEquals($description, html_extract_tag('description', $html));
240 * Test html_extract_tag() when the tag <meta property="og: is not found.
242 public function testHtmlExtractNonExistentOgTag()
244 $html = '<html><meta>stuff2</meta><meta name="image" content="img"/></html>';
245 $this->assertFalse(html_extract_tag('description', $html));
248 public function testHtmlExtractDescriptionFromGoogleRealCase(): void
250 $html = 'id="gsr"><meta content="Fêtes de fin d\'année" property="twitter:title"><meta '.
251 'content="Bonnes fêtes de fin d\'année ! #GoogleDoodle" property="twitter:description">'.
252 '<meta content="Bonnes fêtes de fin d\'année ! #GoogleDoodle" property="og:description">'.
253 '<meta content="summary_large_image" property="twitter:card"><meta co'
255 $this->assertSame('Bonnes fêtes de fin d\'année ! #GoogleDoodle', html_extract_tag('description', $html));
259 * Test the header callback with valid value
261 public function testCurlHeaderCallbackOk(): void
263 $callback = get_curl_header_callback($charset, 'ut_curl_getinfo_ok');
266 'Server: GitHub.com',
267 'Date: Sat, 28 Oct 2017 12:01:33 GMT',
268 'Content-Type: text/html; charset=utf-8',
272 foreach ($data as $chunk) {
273 static::assertIsInt($callback(null, $chunk));
276 static::assertSame('utf-8', $charset);
280 * Test the download callback with valid value
282 public function testCurlDownloadCallbackOk(): void
285 $callback = get_curl_download_callback(
296 . '<title>Refactoring · GitHub</title>'
297 . '<link rel="search" type="application/opensea',
298 '<title>ignored</title>'
299 . '<meta name="description" content="desc" />'
300 . '<meta name="keywords" content="key1,key2" />',
303 foreach ($data as $chunk) {
304 static::assertSame(strlen($chunk), $callback(null, $chunk));
307 static::assertSame('utf-8', $charset);
308 static::assertSame('Refactoring · GitHub', $title);
309 static::assertEmpty($desc);
310 static::assertEmpty($keywords);
314 * Test the header callback with valid value
316 public function testCurlHeaderCallbackNoCharset(): void
318 $callback = get_curl_header_callback($charset, 'ut_curl_getinfo_no_charset');
323 foreach ($data as $chunk) {
324 static::assertSame(strlen($chunk), $callback(null, $chunk));
327 static::assertFalse($charset);
331 * Test the download callback with valid values and no charset
333 public function testCurlDownloadCallbackOkNoCharset(): void
336 $callback = get_curl_download_callback(
346 'end' => 'th=device-width">'
347 . '<title>Refactoring · GitHub</title>'
348 . '<link rel="search" type="application/opensea',
349 '<title>ignored</title>'
350 . '<meta name="description" content="desc" />'
351 . '<meta name="keywords" content="key1,key2" />',
354 foreach ($data as $chunk) {
355 static::assertSame(strlen($chunk), $callback(null, $chunk));
358 $this->assertEmpty($charset);
359 $this->assertEquals('Refactoring · GitHub', $title);
360 $this->assertEmpty($desc);
361 $this->assertEmpty($keywords);
365 * Test the download callback with valid values and no charset
367 public function testCurlDownloadCallbackOkHtmlCharset(): void
370 $callback = get_curl_download_callback(
380 '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />',
381 'end' => 'th=device-width">'
382 . '<title>Refactoring · GitHub</title>'
383 . '<link rel="search" type="application/opensea',
384 '<title>ignored</title>'
385 . '<meta name="description" content="desc" />'
386 . '<meta name="keywords" content="key1,key2" />',
388 foreach ($data as $chunk) {
389 static::assertSame(strlen($chunk), $callback(null, $chunk));
392 $this->assertEquals('utf-8', $charset);
393 $this->assertEquals('Refactoring · GitHub', $title);
394 $this->assertEmpty($desc);
395 $this->assertEmpty($keywords);
399 * Test the download callback with valid values and no title
401 public function testCurlDownloadCallbackOkNoTitle(): void
404 $callback = get_curl_download_callback(
414 'end' => 'th=device-width">Refactoring · GitHub<link rel="search" type="application/opensea',
418 foreach ($data as $chunk) {
419 static::assertSame(strlen($chunk), $callback(null, $chunk));
422 $this->assertEquals('utf-8', $charset);
423 $this->assertEmpty($title);
424 $this->assertEmpty($desc);
425 $this->assertEmpty($keywords);
429 * Test the header callback with an invalid content type.
431 public function testCurlHeaderCallbackInvalidContentType(): void
433 $callback = get_curl_header_callback($charset, 'ut_curl_getinfo_ct_ko');
438 static::assertFalse($callback(null, $data[0]));
439 static::assertNull($charset);
443 * Test the header callback with an invalid response code.
445 public function testCurlHeaderCallbackInvalidResponseCode(): void
447 $callback = get_curl_header_callback($charset, 'ut_curl_getinfo_rc_ko');
449 static::assertFalse($callback(null, ''));
450 static::assertNull($charset);
454 * Test the header callback with an invalid content type and response code.
456 public function testCurlHeaderCallbackInvalidContentTypeAndResponseCode(): void
458 $callback = get_curl_header_callback($charset, 'ut_curl_getinfo_rs_ct_ko');
460 static::assertFalse($callback(null, ''));
461 static::assertNull($charset);
465 * Test the download callback with valid value, and retrieve_description option enabled.
467 public function testCurlDownloadCallbackOkWithDesc(): void
470 $callback = get_curl_download_callback(
480 . '<title>Refactoring · GitHub</title>'
481 . '<link rel="search" type="application/opensea',
482 'end' => '<title>ignored</title>'
483 . '<meta name="description" content="link desc" />'
484 . '<meta name="keywords" content="key1,key2" />',
487 foreach ($data as $chunk) {
488 static::assertSame(strlen($chunk), $callback(null, $chunk));
491 $this->assertEquals('utf-8', $charset);
492 $this->assertEquals('Refactoring · GitHub', $title);
493 $this->assertEquals('link desc', $desc);
494 $this->assertEquals('key1 key2', $keywords);
498 * Test the download callback with valid value, and retrieve_description option enabled,
499 * but no desc or keyword defined in the page.
501 public function testCurlDownloadCallbackOkWithDescNotFound(): void
504 $callback = get_curl_download_callback(
514 . '<title>Refactoring · GitHub</title>'
515 . '<link rel="search" type="application/opensea',
516 'end' => '<title>ignored</title>',
519 foreach ($data as $chunk) {
520 static::assertSame(strlen($chunk), $callback(null, $chunk));
523 $this->assertEquals('utf-8', $charset);
524 $this->assertEquals('Refactoring · GitHub', $title);
525 $this->assertEmpty($desc);
526 $this->assertEmpty($keywords);
530 * Test text2clickable.
532 public function testText2clickable()
534 $text = 'stuff http://hello.there/is=someone#here otherstuff';
535 $expectedText = 'stuff <a href="http://hello.there/is=someone#here">'
536 . 'http://hello.there/is=someone#here</a> otherstuff';
537 $processedText = text2clickable($text);
538 $this->assertEquals($expectedText, $processedText);
540 $text = 'stuff http://hello.there/is=someone#here(please) otherstuff';
541 $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">'
542 . 'http://hello.there/is=someone#here(please)</a> otherstuff';
543 $processedText = text2clickable($text);
544 $this->assertEquals($expectedText, $processedText);
546 $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff';
547 $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff';
548 $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">'
549 . 'http://hello.there/is=someone#here(please)&no</a> otherstuff';
550 $processedText = text2clickable($text);
551 $this->assertEquals($expectedText, $processedText);
555 * Test testSpace2nbsp.
557 public function testSpace2nbsp()
559 $text = ' Are you thrilled by flags ?' . PHP_EOL
. ' Really?';
560 $expectedText = ' Are you thrilled by flags ?' . PHP_EOL
. ' Really?';
561 $processedText = space2nbsp($text);
562 $this->assertEquals($expectedText, $processedText);
566 * Test hashtags auto-link.
568 public function testHashtagAutolink()
570 $index = 'http://domain.tld/';
571 $rawDescription = '#hashtag\n
573 test#nothashtag #hashtag \#nothashtag\n
574 test #hashtag #hashtag test #hashtag.test\n
575 #hashtag #hashtag-nothashtag #hashtag_hashtag\n
576 What is #ашок anyway?\n
578 $autolinkedDescription = hashtag_autolink($rawDescription, $index);
580 $this->assertContainsPolyfill($this->getHashtagLink('hashtag', $index), $autolinkedDescription);
581 $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription);
582 $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription);
583 $this->assertContainsPolyfill($this->getHashtagLink('ашок', $index), $autolinkedDescription);
584 $this->assertContainsPolyfill($this->getHashtagLink('カタカナ', $index), $autolinkedDescription);
585 $this->assertContainsPolyfill($this->getHashtagLink('hashtag_hashtag', $index), $autolinkedDescription);
586 $this->assertNotContainsPolyfill($this->getHashtagLink('hashtag-nothashtag', $index), $autolinkedDescription);
590 * Test hashtags auto-link without index URL.
592 public function testHashtagAutolinkNoIndex()
594 $rawDescription = 'blabla #hashtag x#nothashtag';
595 $autolinkedDescription = hashtag_autolink($rawDescription);
597 $this->assertContainsPolyfill($this->getHashtagLink('hashtag'), $autolinkedDescription);
598 $this->assertNotContainsPolyfill(' #hashtag', $autolinkedDescription);
599 $this->assertNotContainsPolyfill('>#nothashtag', $autolinkedDescription);
603 * Test is_note with note URLs.
605 public function testIsNote()
607 $this->assertTrue(is_note('?'));
608 $this->assertTrue(is_note('?abcDEf'));
609 $this->assertTrue(is_note('?_abcDEf#123'));
613 * Test is_note with non note URLs.
615 public function testIsNotNote()
617 $this->assertFalse(is_note(''));
618 $this->assertFalse(is_note('nope'));
619 $this->assertFalse(is_note('https://github.com/shaarli/Shaarli/?hi'));
623 * Test tags_str2array with whitespace separator.
625 public function testTagsStr2ArrayWithSpaceSeparator(): void
629 static::assertSame(['tag1', 'tag2', 'tag3'], tags_str2array('tag1 tag2 tag3', $separator));
630 static::assertSame(['tag1', 'tag2', 'tag3'], tags_str2array('tag1 tag2 tag3', $separator));
631 static::assertSame(['tag1', 'tag2', 'tag3'], tags_str2array(' tag1 tag2 tag3 ', $separator));
632 static::assertSame(['tag1@', 'tag2,', '.tag3'], tags_str2array(' tag1@ tag2, .tag3 ', $separator));
633 static::assertSame([], tags_str2array('', $separator));
634 static::assertSame([], tags_str2array(' ', $separator));
635 static::assertSame([], tags_str2array(null, $separator));
639 * Test tags_str2array with @ separator.
641 public function testTagsStr2ArrayWithCharSeparator(): void
645 static::assertSame(['tag1', 'tag2', 'tag3'], tags_str2array('tag1@tag2@tag3', $separator));
646 static::assertSame(['tag1', 'tag2', 'tag3'], tags_str2array('tag1@@@@tag2@@@@tag3', $separator));
647 static::assertSame(['tag1', 'tag2', 'tag3'], tags_str2array('@@@tag1@@@tag2@@@@tag3@@', $separator));
649 ['tag1#', 'tag2, and other', '.tag3'],
650 tags_str2array('@@@ tag1# @@@ tag2, and other @@@@.tag3@@', $separator)
652 static::assertSame([], tags_str2array('', $separator));
653 static::assertSame([], tags_str2array(' ', $separator));
654 static::assertSame([], tags_str2array(null, $separator));
658 * Test tags_array2str with ' ' separator.
660 public function testTagsArray2StrWithSpaceSeparator(): void
664 static::assertSame('tag1 tag2 tag3', tags_array2str(['tag1', 'tag2', 'tag3'], $separator));
665 static::assertSame('tag1, tag2@ tag3', tags_array2str(['tag1,', 'tag2@', 'tag3'], $separator));
666 static::assertSame('tag1 tag2 tag3', tags_array2str([' tag1 ', 'tag2', 'tag3 '], $separator));
667 static::assertSame('tag1 tag2 tag3', tags_array2str([' tag1 ', ' ', 'tag2', ' ', 'tag3 '], $separator));
668 static::assertSame('tag1', tags_array2str([' tag1 '], $separator));
669 static::assertSame('', tags_array2str([' '], $separator));
670 static::assertSame('', tags_array2str([], $separator));
671 static::assertSame('', tags_array2str(null, $separator));
675 * Test tags_array2str with @ separator.
677 public function testTagsArray2StrWithCharSeparator(): void
681 static::assertSame('tag1@tag2@tag3', tags_array2str(['tag1', 'tag2', 'tag3'], $separator));
682 static::assertSame('tag1,@tag2@tag3', tags_array2str(['tag1,', 'tag2@', 'tag3'], $separator));
684 'tag1@tag2, and other@tag3',
685 tags_array2str(['@@@@ tag1@@@', ' @tag2, and other @', 'tag3@@@@'], $separator)
687 static::assertSame('tag1@tag2@tag3', tags_array2str(['@@@tag1@@@', '@', 'tag2', '@@@', 'tag3@@@'], $separator));
688 static::assertSame('tag1', tags_array2str(['@@@@tag1@@@@'], $separator));
689 static::assertSame('', tags_array2str(['@@@'], $separator));
690 static::assertSame('', tags_array2str([], $separator));
691 static::assertSame('', tags_array2str(null, $separator));
695 * Test tags_array2str with @ separator.
697 public function testTagsFilterWithSpaceSeparator(): void
701 static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter(['tag1', 'tag2', 'tag3'], $separator));
702 static::assertSame(['tag1,', 'tag2@', 'tag3'], tags_filter(['tag1,', 'tag2@', 'tag3'], $separator));
703 static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter([' tag1 ', 'tag2', 'tag3 '], $separator));
704 static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter([' tag1 ', ' ', 'tag2', ' ', 'tag3 '], $separator));
705 static::assertSame(['tag1'], tags_filter([' tag1 '], $separator));
706 static::assertSame([], tags_filter([' '], $separator));
707 static::assertSame([], tags_filter([], $separator));
708 static::assertSame([], tags_filter(null, $separator));
712 * Test tags_array2str with @ separator.
714 public function testTagsArrayFilterWithSpaceSeparator(): void
718 static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter(['tag1', 'tag2', 'tag3'], $separator));
719 static::assertSame(['tag1,', 'tag2#', 'tag3'], tags_filter(['tag1,', 'tag2#', 'tag3'], $separator));
721 ['tag1', 'tag2, and other', 'tag3'],
722 tags_filter(['@@@@ tag1@@@', ' @tag2, and other @', 'tag3@@@@'], $separator)
724 static::assertSame(['tag1', 'tag2', 'tag3'], tags_filter(['@@@tag1@@@', '@', 'tag2', '@@@', 'tag3@@@'], $separator));
725 static::assertSame(['tag1'], tags_filter(['@@@@tag1@@@@'], $separator));
726 static::assertSame([], tags_filter(['@@@'], $separator));
727 static::assertSame([], tags_filter([], $separator));
728 static::assertSame([], tags_filter(null, $separator));
732 * Util function to build an hashtag link.
734 * @param string $hashtag Hashtag name.
735 * @param string $index Index URL.
737 * @return string HTML hashtag link.
739 private function getHashtagLink($hashtag, $index = '')
741 $hashtagLink = '<a href="' . $index . './add-tag/$1" title="Hashtag $1">#$1</a>';
742 return str_replace('$1', $hashtag, $hashtagLink);