Skip to content

Commit

Permalink
fix: support custom rootPaht on Windows (#29)
Browse files Browse the repository at this point in the history
closes #28
  • Loading branch information
fengmk2 committed Aug 25, 2017
1 parent 1a17fbb commit 4074ec8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,7 +1,7 @@
sudo: false
language: node_js
node_js:
- "7"
- "8"
- "6"
- "4"
- "0.12"
Expand Down
3 changes: 0 additions & 3 deletions README.md
Expand Up @@ -6,7 +6,6 @@ koa-userauth
[![Coveralls][coveralls-image]][coveralls-url]
[![David deps][david-image]][david-url]
[![node version][node-image]][node-url]
[![Gittip][gittip-image]][gittip-url]

[npm-image]: https://img.shields.io/npm/v/koa-userauth.svg?style=flat-square
[npm-url]: https://npmjs.org/package/koa-userauth
Expand All @@ -18,8 +17,6 @@ koa-userauth
[david-url]: https://david-dm.org/koajs/userauth
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.11-red.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[gittip-image]: https://img.shields.io/gittip/dead-horse.svg?style=flat-square
[gittip-url]: https://www.gittip.com/dead-horse/


`koa` user auth abstraction layer middleware.
Expand Down
27 changes: 11 additions & 16 deletions index.js
@@ -1,18 +1,5 @@
/**!
* Copyright(c) koajs and other contributors.
* MIT Licensed
*
* Authors:
* dead_horse <dead_horse@qq.com>
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
*/

'use strict';

/**
* Module dependencies.
*/

var debug = require('debug')('koa-userauth');
var path = require('path');
var is = require('is-type-of');
Expand Down Expand Up @@ -63,9 +50,17 @@ module.exports = function (options) {
|| options.loginPath + '/callback';

if (options.rootPath !== '/') {
options.loginPath = path.join(options.rootPath, options.loginPath);
options.logoutPath = path.join(options.rootPath, options.logoutPath);
options.loginCallbackPath = path.join(options.rootPath, options.loginCallbackPath);
if (process.platform === 'win32') {
// rtrim last /, '/foo/' => '/foo'
var rootPath = options.rootPath.replace(/\/+$/, '');
options.loginPath = rootPath + options.loginPath;
options.logoutPath = rootPath + options.logoutPath;
options.loginCallbackPath = rootPath + options.loginCallbackPath;
} else {
options.loginPath = path.join(options.rootPath, options.loginPath);
options.logoutPath = path.join(options.rootPath, options.logoutPath);
options.loginCallbackPath = path.join(options.rootPath, options.loginCallbackPath);
}
}

// all the typos. T_T
Expand Down
13 changes: 0 additions & 13 deletions test/index.test.js
@@ -1,18 +1,5 @@
/**
* Copyright(c) koajs and other contributors.
* MIT Licensed
*
* Authors:
* dead_horse <dead_horse@qq.com>
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)
*/

'use strict';

/**
* Module dependencies.
*/

var pedding = require('pedding');
var mm = require('mm');
var should = require('should');
Expand Down

0 comments on commit 4074ec8

Please sign in to comment.