Пример #1
0
 public function testMakeInternalLinksRelative()
 {
     $replacements = ["<a href='https://localhost/test'>test</a>" => "<a href='/test'>test</a>", "<a href='http://localhost/test'>test</a>" => "<a href='/test'>test</a>", '<a href="https://localhost/test">test</a>' => '<a href="/test">test</a>', '<a href="http://localhost/test">test</a>' => '<a href="/test">test</a>', "<a href='https://localhost/test'>https://localhost/test</a>" => "<a href='/test'>https://localhost/test</a>", 'localhost/test' => 'localhost/test', "<a href='https://www.localhost.com/test'></a>" => "<a href='https://www.localhost.com/test'></a>", "<a href='https://localhost/test?query=test#test'>test</a>" => "<a href='/test?query=test#test'>test</a>"];
     foreach ($replacements as $original => $after) {
         $this->AssertEquals($after, Str::makeInternalLinksRelative($original));
     }
 }
Пример #2
0
 public function setTextAttribute($text)
 {
     $text = str_replace('&nbsp;', ' ', $text);
     if ($this->slotname === 'standfirst') {
         $siteText = $text = strip_tags($text);
     } else {
         $text = Str::makeInternalLinksRelative($text);
         $siteText = Str::StorifyEmbed(Str::OEmbed($text));
     }
     $this->attributes['text'] = $text;
     $this->attributes['site_text'] = $siteText;
 }