Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4系 getTagLinkUrlで取得するタグの名称をurlエンコード #4116

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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]],
];
}

@@ -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']
];
}

@@ -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']
];
}

4 changes: 2 additions & 2 deletions lib/Baser/Plugin/Blog/View/Helper/BlogHelper.php
Original file line number Diff line number Diff line change
@@ -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;