diff --git a/core/modules/path/src/Tests/PathAliasTest.php b/core/modules/path/src/Tests/PathAliasTest.php
index 7a58787..b5ae05f 100644
--- a/core/modules/path/src/Tests/PathAliasTest.php
+++ b/core/modules/path/src/Tests/PathAliasTest.php
@@ -233,6 +233,11 @@ function testNodeAlias() {
     // Create test node.
     $node1 = $this->drupalCreateNode();
 
+    // Get node and check drupalSettings.
+    $node1 = $this->drupalCreateNode();
+    $this->drupalGet('node/' . $node1->id());
+    $this->assertIdentical($this->getDrupalSettings()['path']['currentPath'], 'node/' . $node1->id());
+
     // Create alias.
     $edit = array();
     $edit['path[0][alias]'] = '/' . $this->randomMachineName(8);
@@ -242,6 +247,7 @@ function testNodeAlias() {
     $this->drupalGet($edit['path[0][alias]']);
     $this->assertText($node1->label(), 'Alias works.');
     $this->assertResponse(200);
+    $this->assertIdentical($this->getDrupalSettings()['path']['currentPath'], substr($edit['path[0][alias]'], 1));
 
     // Confirm the 'canonical' and 'shortlink' URLs.
     $elements = $this->xpath("//link[contains(@rel, 'canonical') and contains(@href, '" . $edit['path[0][alias]'] . "')]");
@@ -307,6 +313,7 @@ function testNodeAlias() {
     $this->drupalGet(trim($edit['path[0][alias]'], '/'));
     $this->assertText($node3->label(), 'Alias became relative.');
     $this->assertResponse(200);
+    $this->assertIdentical($this->getDrupalSettings()['path']['currentPath'], substr($edit['path[0][alias]'], 1));
 
     // Create fourth test node.
     $node4 = $this->drupalCreateNode();
@@ -319,6 +326,7 @@ function testNodeAlias() {
     $this->drupalGet(trim($edit['path[0][alias]'], '/'));
     $this->assertText($node4->label(), 'Alias trimmed trailing slash.');
     $this->assertResponse(200);
+    $this->assertIdentical($this->getDrupalSettings()['path']['currentPath'], trim(substr($edit['path[0][alias]'], 1), '/'));
   }
 
   /**
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 85f55ed..9671afe 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -690,7 +690,10 @@ 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 = $route_match->getRouteName() ? substr($request->getPathInfo(), 1) : '';
+  if ($pathPrefix && strpos($current_path, $pathPrefix) === 0) {
+    $current_path = substr_replace($current_path, '', 0, strlen($pathPrefix));
+  }
   $current_path_is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route_match->getRouteObject());
   $path_settings = [
     'baseUrl' => $request->getBaseUrl() . '/',
