From c02d2afc095d0ef001afb5d7b1988d0ce56d4697 Mon Sep 17 00:00:00 2001 From: Yves Torres Date: Thu, 25 Sep 2025 17:01:51 +0200 Subject: [PATCH 1/4] Include hash parameter in URL generation Add hash parameter to URL rewriting logic. --- lib/yrewrite/yrewrite.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/yrewrite/yrewrite.php b/lib/yrewrite/yrewrite.php index 9c55cfb..ad21b02 100644 --- a/lib/yrewrite/yrewrite.php +++ b/lib/yrewrite/yrewrite.php @@ -265,6 +265,7 @@ public static function rewrite($params = [], $yparams = [], $fullpath = false) if (isset($redirections[$id][$clang])) { $params['id'] = $redirections[$id][$clang]['id']; $params['clang'] = $redirections[$id][$clang]['clang']; + $params['hash'] = $redirections[$id][$clang]['hash']; return self::rewrite($params, $yparams, $fullpath); } } @@ -298,7 +299,7 @@ public static function rewrite($params = [], $yparams = [], $fullpath = false) $urlparams = rex_string::buildQuery($params['params'], $params['separator']); } - return $path . ($urlparams ? '?' . $urlparams : ''); + return $path . ($urlparams ? '?' . $urlparams : '') . (isset($params['hash']) ? '#' . $params['hash'] : ''); } public static function rewriteMedia(array $params) From 453bfa0980e3417807292d10447dee969061d885 Mon Sep 17 00:00:00 2001 From: Yves Torres Date: Thu, 25 Sep 2025 17:03:20 +0200 Subject: [PATCH 2/4] Add hash extraction to redirection handling --- lib/yrewrite/path_generator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/yrewrite/path_generator.php b/lib/yrewrite/path_generator.php index 428b52c..a2a50dd 100644 --- a/lib/yrewrite/path_generator.php +++ b/lib/yrewrite/path_generator.php @@ -156,10 +156,12 @@ private function setPath(rex_article $article, rex_yrewrite_domain $domain, stri } if ($redirection instanceof rex_structure_element) { + [$_articleId, $hash] = array_pad(explode('#', $article->getValue('yrewrite_redirection'), 2), 2, null); $this->redirections[$domainName][$articleId][$clangId] = [ 'id' => $redirection->getId(), 'clang' => $redirection->getClangId(), 'path' => $url, + 'hash' => $hash, ]; unset($this->paths[$domainName][$articleId][$clangId]); From f5cff7e62d946de2d15b220a47569221342cd7c9 Mon Sep 17 00:00:00 2001 From: Yves Torres Date: Tue, 11 Nov 2025 15:39:27 +0100 Subject: [PATCH 3/4] Implement hash fragment handling in URL path Add handling for hash fragments in URL rewriting. --- lib/yrewrite/yrewrite.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/yrewrite/yrewrite.php b/lib/yrewrite/yrewrite.php index ad21b02..9f036a3 100644 --- a/lib/yrewrite/yrewrite.php +++ b/lib/yrewrite/yrewrite.php @@ -299,6 +299,19 @@ public static function rewrite($params = [], $yparams = [], $fullpath = false) $urlparams = rex_string::buildQuery($params['params'], $params['separator']); } + // check if we already have a hash in $path + $hashFragment = parse_url($path, PHP_URL_FRAGMENT); + if ($hashFragment) { + if (isset($params['hash'])) { + // override hash from params + $path = str_replace('#' . $hashFragment, '#' . $params['hash'], $path); + } else { + // use hash from path + $path = str_replace('#' . $hashFragment, '', $path); + $params['hash'] = $hashFragment; + } + } + return $path . ($urlparams ? '?' . $urlparams : '') . (isset($params['hash']) ? '#' . $params['hash'] : ''); } From 7f2c8fef83b20b30ee8a7e2304ec0be7e2b7e882 Mon Sep 17 00:00:00 2001 From: Yves Torres Date: Tue, 11 Nov 2025 15:51:25 +0100 Subject: [PATCH 4/4] Remove unnecessary whitespace in yrewrite.php --- lib/yrewrite/yrewrite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yrewrite/yrewrite.php b/lib/yrewrite/yrewrite.php index 9f036a3..219f60a 100644 --- a/lib/yrewrite/yrewrite.php +++ b/lib/yrewrite/yrewrite.php @@ -311,7 +311,7 @@ public static function rewrite($params = [], $yparams = [], $fullpath = false) $params['hash'] = $hashFragment; } } - + return $path . ($urlparams ? '?' . $urlparams : '') . (isset($params['hash']) ? '#' . $params['hash'] : ''); }