From 3d1255553bfb9cbd1a2be1448ca21f789af58ed7 Mon Sep 17 00:00:00 2001 From: longze Date: Wed, 20 Sep 2017 17:02:15 +0800 Subject: [PATCH] bug fix: can not find the path: undefined --- index.js | 16 +++++++--------- package.json | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index bd684ea..6a97532 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,10 @@ -'use strict'; - /** - * Module dependencies. + * @file 功能文件 + * @author longze */ +'use strict'; + const assert = require('assert'); const fs = require('fs'); const resolve = require('path').resolve; @@ -34,9 +35,6 @@ function getData(path, req, res, next) { console.log(e); } } - else { - body = 'can not find the path: ' + absolutePath; - } return body; } @@ -44,7 +42,7 @@ function getData(path, req, res, next) { /** * auto path router from `root`. * - * @param {String} root + * @param {string} rootPath mock文件夹根路径 * @return {Function} * @api public */ @@ -52,7 +50,7 @@ function mock(rootPath) { assert(rootPath, 'root path directory is required to serve files'); rootPath = resolve(rootPath); - + return function (req, res, next) { let pathname = url.parse(req.url).pathname; let path = rootPath + '/' + req.method + pathname; @@ -64,4 +62,4 @@ function mock(rootPath) { next(); } }; -} \ No newline at end of file +} diff --git a/package.json b/package.json index 460583e..9e01b4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "express-auto-path-router", - "version": "1.3.0", + "version": "1.3.1", "description": "Auto path router serving middleware for express", "scripts": { "test": "node ./node_modules/.bin/mocha",