Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from davidyell/allow-fixed-domain
Browse files Browse the repository at this point in the history
Allow a fixed domain
  • Loading branch information
davidyell authored Mar 12, 2020
2 parents c151bc3 + a6a810c commit c347777
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ install:
- composer install --prefer-dist --no-interaction --dev

before_script:
- sh -c "if [ '$PHPCS' = '1' ]; then composer require cakephp/cakephp-codesniffer; fi"
- sh -c "if [ '$PHPCS' = '1' ]; then composer require cakephp/cakephp-codesniffer:~3.0; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then composer require --dev satooshi/php-coveralls; fi"
- sh -c "if [ '$COVERALLS' = '1' ]; then mkdir -p build/logs; fi"

Expand Down
10 changes: 8 additions & 2 deletions src/View/Helper/SeoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class SeoHelper extends Helper
* @var array
*/
protected $_defaultConfig = [
'paginatedControllers' => []
'paginatedControllers' => [],
'domain' => null
];

/**
Expand Down Expand Up @@ -63,7 +64,12 @@ public function pagination(string $controllerName): ?string
public function canonical(): string
{
$parsedUrl = parse_url($this->request->getUri()->getPath());
$url = Router::fullbaseUrl() . preg_replace("/[^\w\d\-\/]+/", "-", $parsedUrl['path']);

$domain = Router::fullbaseUrl();
if ($this->getConfig('domain') !== null) {
$domain = $this->getConfig('domain');
}
$url = $domain . preg_replace("/[^\w\d\-\/]+/", "-", $parsedUrl['path']);

return "<link rel='canonical' href='$url'>";
}
Expand Down

0 comments on commit c347777

Please sign in to comment.