diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 85f55ed..ed05278 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -690,7 +690,7 @@ function system_js_settings_alter(&$settings, AttachedAssetsInterface $assets) {
   if ($route_match instanceof StackedRouteMatchInterface) {
     $route_match = $route_match->getMasterRouteMatch();
   }
-  $current_path = $route_match->getRouteName() ? Url::fromRouteMatch($route_match)->getInternalPath() : '';
+  $current_path = substr($request->getPathInfo(), 1);
   $current_path_is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route_match->getRouteObject());
   $path_settings = [
     'baseUrl' => $request->getBaseUrl() . '/',
