ctx.matchedPath now stores raw route rather than processed array
[squeep-api-dingus] / lib / router / index.js
index f0d2d945a53909c327ab1661c54e83e9a6cfe097..1585065e14ce79b804cd6de967965951ab0d535a 100644 (file)
@@ -69,6 +69,12 @@ class Router {
     }
 
     routePath[kPathMethods] = {};
+
+    Object.defineProperty(routePath, 'path', {
+      enumerable: false,
+      value: rawPath,
+    });
+
     Object.freeze(routePath);
     return routePath;
   }
@@ -253,7 +259,7 @@ class Router {
     const { matchedPath, pathParams } = this._pathFind(pathParts);
     ctx.params = pathParams;
     if (matchedPath) {
-      ctx.matchedPath = matchedPath;
+      ctx.matchedPath = matchedPath.path;
       if (method in matchedPath[kPathMethods]) {
         return matchedPath[kPathMethods][method];
       }