Skip to content

Commit

Permalink
getTagLinkUrlで取得するタグの名称をurlエンコード
Browse files Browse the repository at this point in the history
  • Loading branch information
seto1 authored Jan 23, 2025
1 parent ceed85c commit 3ff0a93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
30 changes: 15 additions & 15 deletions lib/Baser/Plugin/Blog/Test/Case/View/Helper/BlogHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,10 @@ public function testTagList($expected, $name, $options = [])
public function tagListDataProvider()
{
return [
['/(?=\/tag\/タグ1).*?(?!.*\/tag\/タグ2).*?(?!.*\/tag\/タグ3)/s', 'blog1'],
['/(?=\/tag\/タグ1).*?(?=\/tag\/タグ2).*?(?=\/tag\/タグ3)/s', '/s/blog3/'],
['/(?=\/tags\/タグ1).*?(?=\/tags\/タグ2).*?(?=\/tags\/タグ3).*?(?=\/tags\/タグ4).*?(?=\/tags\/タグ5)/s', null],
['/(?=\/tag\/タグ1).*?\(2\)/s', 'blog1', ['postCount' => true]],
['/(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%91).*?(?!.*\/tag\/%E3%82%BF%E3%82%B0%EF%BC%92).*?(?!.*\/tag\/%E3%82%BF%E3%82%B0%EF%BC%93)/s', 'blog1'],
['/(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%91).*?(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%92).*?(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%93)/s', '/s/blog3/'],
['/(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%91).*?(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%92).*?(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%93).*?(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%94).*?(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%95)/s', null],
['/(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%91).*?\(2\)/s', 'blog1', ['postCount' => true]],
];
}

Expand Down Expand Up @@ -836,13 +836,13 @@ public function testGetTagLinkUrl($currentUrl, $blogContentId, $name, $base, $us
public function getTagLinkUrlDataProvider()
{
return [
['/', 1, 'タグ1', '', false, '/news/archives/tag/タグ1'],
['/', 1, 'タグ1', '/sub', false, '/news/archives/tag/タグ1'],
['/', 1, 'タグ1', '/sub', true, '/sub/news/archives/tag/タグ1'],
['/en/', 3, 'タグ2', '', false, '/en/news/archives/tag/タグ2'],
['/', 4, 'タグ2', '', false, 'http://sub.main.com/news/archives/tag/タグ2'],
['/', null, 'タグ1', '', false, '/tags/タグ1'],
['/s/', null, 'タグ2', '', false, '/s/tags/タグ2']
['/', 1, 'タグ1', '', false, '/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%91'],
['/', 1, 'タグ1', '/sub', false, '/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%91'],
['/', 1, 'タグ1', '/sub', true, '/sub/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%91'],
['/en/', 3, 'タグ2', '', false, '/en/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%92'],
['/', 4, 'タグ2', '', false, 'http://sub.main.com/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%92'],
['/', null, 'タグ1', '', false, '/tags/%E3%82%BF%E3%82%B0%EF%BC%91'],
['/s/', null, 'タグ2', '', false, '/s/tags/%E3%82%BF%E3%82%B0%EF%BC%92']
];
}

Expand Down Expand Up @@ -871,10 +871,10 @@ public function testGetTagLink($expected, $currentUrl, $blogContentId, $name)
public function getTagLinkDataProvider()
{
return [
['<a href="/news/archives/tag/タグ1">タグ1</a>', '/', 1, 'タグ1'],
['<a href="/s/blog3/archives/tag/タグ2">タグ2</a>', '/s/', 3, 'タグ2'],
['<a href="/tags/タグ1">タグ1</a>', '/', null, 'タグ1'],
['<a href="/s/tags/タグ2">タグ2</a>', '/s/', null, 'タグ2']
['<a href="/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%91">タグ1</a>', '/', 1, 'タグ1'],
['<a href="/s/blog3/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%92">タグ2</a>', '/s/', 3, 'タグ2'],
['<a href="/tags/%E3%82%BF%E3%82%B0%EF%BC%91">タグ1</a>', '/', null, 'タグ1'],
['<a href="/s/tags/%E3%82%BF%E3%82%B0%EF%BC%92">タグ2</a>', '/s/', null, 'タグ2']
];
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Baser/Plugin/Blog/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1452,11 +1452,11 @@ public function getTagLinkUrl($blogContentId, $tag, $base = true)
if (!empty($this->content['url'])) {
$site = BcSite::findByUrl($this->content['url']);
$url = $this->BcBaser->getContentsUrl($this->content['url'], !$this->isSameSiteBlogContent($blogContentId), !empty($site->useSubDomain), false);
$url = $url . 'archives/tag/' . $tag['name'];
$url = $url . 'archives/tag/' . rawurlencode($tag['name']);
}
}
if (!$url) {
$url = '/tags/' . $tag['name'];
$url = '/tags/' . rawurlencode($tag['name']);
$site = BcSite::findCurrent(true);
if ($site && $site->alias && !$site->useSubDomain) {
$url = '/' . $site->alias . $url;
Expand Down

0 comments on commit 3ff0a93

Please sign in to comment.