Skip to content

Commit

Permalink
Create item hashes from only the menu path
Browse files Browse the repository at this point in the history
MAP-383
  • Loading branch information
Bill Tomczak committed Feb 6, 2018
1 parent 3876c01 commit 686248c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/admin/library/alledia/osmap/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,17 @@ public function removeHashFromURL($url)

return $url;
}

/**
* Create a consistent url hash regardless of scheme or site root.
*
* @param string $url
*
* @return string
* @throws \Exception
*/
public function createUrlHash($url)
{
return md5(str_replace(Factory::getContainer()->uri->root(), '', $url));
}
}
2 changes: 1 addition & 1 deletion src/admin/library/alledia/osmap/Sitemap/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ protected function checkDuplicatedURLToIgnore($item)

// We need to make sure to have an URL free of hash chars
$url = $container->router->removeHashFromURL($item->fullLink);
$hash = md5($url);
$hash = $container->router->createUrlHash($url);

if (isset($this->urlHashList[$hash])) {
$item->duplicate = true;
Expand Down
2 changes: 1 addition & 1 deletion src/admin/library/alledia/osmap/Sitemap/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function __construct($itemData, $currentMenuItemId)
$this->fullLink = $container->router->removeHashFromURL($this->fullLink);

// Make sure to have a unique hash for the settings
$this->settingsHash = md5($this->fullLink . $currentMenuItemId);
$this->settingsHash = $container->router->createUrlHash($this->fullLink . $currentMenuItemId);

/*
* Do not use a "prepare" method because we need to make sure it will
Expand Down

0 comments on commit 686248c

Please sign in to comment.