Index: src/wp-includes/rest-api/class-wp-rest-server.php
===================================================================
--- src/wp-includes/rest-api/class-wp-rest-server.php	(revision 40596)
+++ src/wp-includes/rest-api/class-wp-rest-server.php	(working copy)
@@ -824,12 +824,21 @@
 		$path   = $request->get_route();
 
 		foreach ( $this->get_routes() as $route => $handlers ) {
-			$match = preg_match( '@^' . $route . '$@i', $path, $args );
+			$match = preg_match( '@^' . $route . '$@i', $path, $matches );
 
 			if ( ! $match ) {
 				continue;
 			}
 
+			$args = array();
+			foreach ( $matches as $param => $value ) {
+				if ( is_int( $param ) ) {
+					continue;
+				}
+
+				$args[ $param ] = $value;
+			}
+
 			foreach ( $handlers as $handler ) {
 				$callback  = $handler['callback'];
 				$response = null;
