Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
redirect
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
redirect
Merge requests
!68
Resolve
#3394858
"Language redirects should be temporary"
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Open
Resolve
#3394858
"Language redirects should be temporary"
issue/redirect-3394858:3394858-language-redirects-should
into
8.x-1.x
Overview
0
Commits
2
Pipelines
0
Changes
1
Open
Resolve #3394858 "Language redirects should be temporary"
Guillaume Pacilly
requested to merge
issue/redirect-3394858:3394858-language-redirects-should
into
8.x-1.x
Oct 20, 2023
Overview
0
Commits
2
Pipelines
0
Changes
1
Closes
#3394858
0
0
Merge request reports
Compare
8.x-1.x
8.x-1.x (HEAD)
and
latest version
latest version
69cd3d83
2 commits,
Oct 20, 2023
1 file
+
14
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/EventSubscriber/RouteNormalizerRequestSubscriber.php
+
14
−
1
View file @ f696c0d0
Edit in single-file editor
Open in Web IDE
Show full file
@@ -136,7 +136,20 @@ class RouteNormalizerRequestSubscriber implements EventSubscriberInterface {
$original_uri
=
$request
->
getSchemeAndHttpHost
()
.
$request
->
getRequestUri
();
$original_uri
=
urldecode
(
$original_uri
);
if
(
urldecode
(
$redirect_uri
)
!=
$original_uri
)
{
$response
=
new
TrustedRedirectResponse
(
$redirect_uri
,
$this
->
config
->
get
(
'default_status_code'
));
$status_code
=
$this
->
config
->
get
(
'default_status_code'
);
$language_negotiation_config
=
\Drupal
::
config
(
'language.negotiation'
)
->
get
(
'url'
);
$current_langcode
=
\Drupal
::
languageManager
()
->
getCurrentLanguage
()
->
getId
();
if
(
$language_negotiation_config
[
'source'
]
==
"path_prefix"
)
{
$prefix
=
$language_negotiation_config
[
'prefixes'
][
$current_langcode
];
$redirect_relative_uri
=
$this
->
urlGenerator
->
generateFromRoute
(
$route_name
);
$prefixed_original_uri
=
rtrim
(
'/'
.
$prefix
.
$request
->
getRequestUri
(),
'/'
);
if
(
urldecode
(
$redirect_relative_uri
)
==
$prefixed_original_uri
)
{
// Language redirections should be 302 as they are temporary.
$status_code
=
302
;
}
}
$response
=
new
TrustedRedirectResponse
(
$redirect_uri
,
$status_code
);
$response
->
headers
->
set
(
'X-Drupal-Route-Normalizer'
,
1
);
$event
->
setResponse
(
$response
);
}
Loading