Force redirect/route matching from start of route #1446

This commit is contained in:
Andy Miller
2017-04-24 17:57:47 -06:00
parent e8aa9f0381
commit 2074c4933a
2 changed files with 8 additions and 2 deletions

View File

@@ -1,3 +1,9 @@
# v1.2.5
## 04/xx/2017
1. [](#bugfix)
* Fix to force route/redirect matching from the start of the route by default [1446](https://github.com/getgrav/grav/issues/1446)
# v1.2.4
## 04/24/2017

View File

@@ -405,7 +405,7 @@ class Pages
$site_redirects = $config->get("site.redirects");
if (is_array($site_redirects)) {
foreach ((array)$site_redirects as $pattern => $replace) {
$pattern = '#' . $pattern . '#';
$pattern = '#^' . preg_quote(ltrim($pattern, '^')) . '#';
try {
$found = preg_replace($pattern, $replace, $source_url);
if ($found != $source_url) {
@@ -421,7 +421,7 @@ class Pages
$site_routes = $config->get("site.routes");
if (is_array($site_routes)) {
foreach ((array)$site_routes as $pattern => $replace) {
$pattern = '#' . $pattern . '#';
$pattern = '#^' . preg_quote(ltrim($pattern, '^')) . '#';
try {
$found = preg_replace($pattern, $replace, $source_url);
if ($found != $source_url) {