- Issue created by @idiaz.roncero
- πͺπΈSpain idiaz.roncero Madrid
Drupal will convert internally any path alias that is stored under
system.site.page.front
config to its unaliased path, seeDrupal\system\Form::validateForm
andDrupal\system\Form::submitForm
:/** * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { // Get the normal path of the front page. $form_state->setValueForElement($form['front_page']['site_frontpage'], $this->aliasManager->getPathByAlias($form_state->getValue('site_frontpage')));
I think then it is safe to always assume the drupal site front page will be expresed as an un-aliased path and request the current request URL also as the unprocessed one:
$path = parse_url($url->setOption('path_processing', false)->toString(), PHP_URL_PATH);
As far as i can tell from looking at the code, the quickest solution is to bypass the path processing option when generating the URL string
- @idiazroncero opened merge request.
- Status changed to Needs review
about 1 year ago 9:46am 25 October 2023 - πͺπΈSpain idiaz.roncero Madrid
Explanation: i'm not using the more mainstream
$url->getInternalPath()
method because it returns an un-slashednode/NID
path that needs to be compared with an slashed/node/NID
path.Passing
path_processing
seems to work as it will return the slashed path. - First commit to issue fork.
- πΊπΈUnited States jrockowitz Brooklyn, NY
I tweaked the code and added some more test coverage.
- πΊπΈUnited States jrockowitz Brooklyn, NY
So the new tests pass locally but fail via GitLab CI. I might comment out the failing test and deal with it later.
-
jrockowitz β
committed dfa8ee9d on 1.0.x authored by
idiaz.roncero β
Issue #3396552: Custom JSON LD not working on frontpage when using path...
-
jrockowitz β
committed dfa8ee9d on 1.0.x authored by
idiaz.roncero β
- Status changed to Fixed
about 1 year ago 5:37pm 30 October 2023 Automatically closed - issue fixed for 2 weeks with no activity.