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

PermalinkGenerator: Keep title_path as-is with preserve_title_path #90

Merged
merged 1 commit into from
Jun 5, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Core/ContentManager/Permalink/PermalinkGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ private function getTitleSlugified(ItemInterface $item)
$preservePathTitle = $this->getPreservePathTitleAttribute($item);

if ($preservePathTitle === true && isset($attributes['title_path']) === true) {
return (new StringWrapper($attributes['title_path']))->slug();
return $attributes['title_path'];
Copy link
Member

@yosymfony yosymfony Jun 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, if you are using certain characters such as spaces, you'll get a bad permalink but I understand that if you turn on preserve_title_path feature is because you want to preserver the title from the path and it is under your risk

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, well then maybe use urlencode() instead of slug(), so e.g.
spaces are turned to %20 and such, to try and ensure good/valid URLs,
but nothing else.

}

if (isset($attributes['title']) === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ public function testPreservePathTitle()

$this->assertEquals('title-post/index.html', $permalink->getPath());
$this->assertEquals('/title-post/index.html', $permalink->getUrlPath());

$permalink = $pmg->getPermalink($this->createItem('index.html', [
'date' => '2015-04-17',
'title' => 'title post',
'title_path' => 'title-WITH-1.2.3',
]));

$this->assertEquals('title-WITH-1.2.3/index.html', $permalink->getPath());
$this->assertEquals('/title-WITH-1.2.3/index.html', $permalink->getUrlPath());
}

public function testNoHtmlExtension()
Expand Down