Comparing version 5.0.2 to 5.0.3-beta
@@ -36,3 +36,23 @@ 'use strict' | ||
function fmtpath (path) { | ||
path = path.trim() | ||
if (path.length == 0) { | ||
return '/*' | ||
} | ||
if (path[0] !== '/') { | ||
path = `/${path}` | ||
} | ||
if (path.length > 1 && path[path.length - 1] !== '/') { | ||
path = `${path}/` | ||
} | ||
if (path.indexOf('/:') >= 0) { | ||
return path.substring(0, path.length-1) | ||
} | ||
return `${path}*` | ||
} | ||
let hiiproxy = function (options = {}) { | ||
@@ -75,2 +95,6 @@ | ||
case 'starPath': | ||
this.starPath = !!options[k] | ||
break | ||
case 'maxBody': | ||
@@ -111,2 +135,8 @@ case 'addIP': | ||
tmp.path = tmp.path.trim().replace(/(\/){2,}/g, '/') | ||
if (tmp.path.length > 2 && tmp.path[tmp.path.length - 1] === '/') { | ||
tmp.path = tmp.substring(0, tmp.path.length-1) | ||
} | ||
if (tmp.url === undefined) { | ||
@@ -160,2 +190,5 @@ console.error(`${k} ${tmp.path}:没有指定要代理转发的url。`) | ||
if (tmp.rewrite && typeof tmp.rewrite === 'function') | ||
backend_obj.rewrite = tmp.rewrite | ||
} | ||
@@ -188,2 +221,4 @@ | ||
path : tmp.path, | ||
pathLength: tmp.path.length, | ||
rewrite: false, | ||
weight: 1, | ||
@@ -346,2 +381,7 @@ weightCount : 0, | ||
if (pr.rewrite) { | ||
let rpath = pr.rewrite(c, c.headers[':path']) | ||
if (rpath) c.headers[':path'] = rpath | ||
} | ||
let stm = hii.session.request(c.headers) | ||
@@ -413,23 +453,3 @@ | ||
function fmtpath (path) { | ||
path = path.trim() | ||
if (path.length == 0) { | ||
return '/*' | ||
} | ||
if (path[0] !== '/') { | ||
path = `/${path}` | ||
} | ||
if (path.length > 1 && path[path.length - 1] !== '/') { | ||
path = `${path}/` | ||
} | ||
if (path.indexOf('/:') >= 0) { | ||
return path.substring(0, path.length-1) | ||
} | ||
return `${path}*` | ||
} | ||
module.exports = hiiproxy |
{ | ||
"name": "gohttp", | ||
"version": "5.0.2", | ||
"version": "5.0.3-beta", | ||
"description": "http & https client for HTTP/1.1 and HTTP/2", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109152
2038
2