Skip to content

Commit

Permalink
Merge branch 'dev' into USAGOV-2086-get-events-error
Browse files Browse the repository at this point in the history
  • Loading branch information
akf authored Nov 19, 2024
2 parents eaa94f0 + 3122d41 commit af2d493
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,13 @@ public function modifyHtml(ModifyHtmlEvent $event) {
public function excludeInvalidPaths(PathPlaceholderEvent $event) {
$path = $event->getPath();

if ($path === '/es/') {
// Tome should never request the spanish homepage with a trailing-slash.
// If it does request it, that is due to the path being linked in content.
// When tome runs, Drupal will redirect the request to `/es`, causing Tome
// to rewrite the contents of `es/index.html` with a refresh redirect.
if ($path !== '/' && str_ends_with($path, '/')) {
// Tome should never request the Spanish homepage or any other local path
// with a trailing-slash. If it does request it, that is because the path
// was found in the content of a node or term.
// For example, when tome runs and it finds a link to `/es/`, Drupal will
// redirect the request for `/es/` to `/es`. The response causes Tome to
// save it in the contents of `es/index.html` with an refresh redirect.
$event->setInvalid();
return;
}
Expand Down
13 changes: 13 additions & 0 deletions web/modules/custom/usagov_wizard/usagov_wizard.module
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,19 @@ function usagov_wizard_preprocess_html(&$variables) {
$variables['wizardTitle'] = $wizard_title;
$variables['wizardTitleUrl'] = $wizard_title_url;
}
else {
$parents = $menuChecker->getTermParents($taxonomy_term);
$topParent = Term::load($parents[0]);

$variables['wizardTitle'] = $topParent->getName();
$variables['wizardTitleUrl'] = \Drupal::service('path_alias.manager')->getAliasByPath('/taxonomy/term/' . $topParent->id());

// Make sure Spanish-paths are prefixed with /es/
$langCode = $taxonomy_term->language()->getId();
if ($langCode == 'es' && !str_starts_with($variables['wizardTitleUrl'], '/es/')) {
$variables['wizardTitleUrl'] = '/' . $langCode . $variables['wizardTitleUrl'];
}
}
}
}
}
Expand Down

0 comments on commit af2d493

Please sign in to comment.