Skip to content

Commit

Permalink
Fix eslint “errors”
Browse files Browse the repository at this point in the history
  • Loading branch information
17320 committed Oct 5, 2018
1 parent 496e722 commit e407d92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lib/middlewares/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

var proxy = require('http-proxy-middleware');

module.exports = function (app) {
module.exports = function(app) {
var config = this.config;
var args = this.env.args || {};
var proxyPath = args.P || args.proxyPath || config.server.proxyPath || process.env.proxy_path;
var proxyUrl = args.U || args.proxyUrl || config.server.proxyUrl || process.env.proxy_url;
if (!proxyPath || !proxyUrl) return;

if(!proxyPath || !proxyUrl) return;

// In case of multiple proxy-url options, ignore all but last.
if (Array.isArray(proxyUrl)) {
if(Array.isArray(proxyUrl)) {
proxyUrl = proxyUrl[proxyUrl.length - 1];
}
app.use (proxyPath, proxy({target: proxyUrl, changeOrigin: true}));

app.use(proxyPath, proxy({target: proxyUrl, changeOrigin: true}));
};
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ describe('server', function() {
proxyPath: '/proxy',
proxyUrl: 'http://localhost:17320/'
}, hexo.config.server);
var fakeServer = http.createServer(function (req, res) {

var fakeServer = http.createServer(function(req, res) {
res.end('OK');
}).listen(17320);

Expand Down

0 comments on commit e407d92

Please sign in to comment.