Skip to content

Commit

Permalink
feat: handle tunnel rules
Browse files Browse the repository at this point in the history
  • Loading branch information
avwo committed Aug 10, 2018
1 parent fe0ced5 commit 8c1859a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/init.js
Expand Up @@ -111,7 +111,7 @@ module.exports = function(req, res, next) {
var tunnelRules = req.headers[TUNNEL_KEY];
if (tunnelRules) {
try {
socket.tunnelRules = JSON.parse(tunnelRules);
socket.tunnelRules = JSON.parse(decodeURIComponent(tunnelRules));
} catch(e) {}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/index.js
Expand Up @@ -292,7 +292,7 @@ function getTunneRules(req) {
tunnelRules = req.headers[TUNNEL_KEY];
if (tunnelRules) {
try {
return JSON.parse(tunnelRules);
return JSON.parse(decodeURIComponent(tunnelRules));
} catch(e) {}
}
return '';
Expand Down Expand Up @@ -324,7 +324,7 @@ function getHost(req, tunnelRules) {
if (tunnelHost && host !== tunnelHost && tunnelHost !== getFullHost(req)) {
tunnelHost = host.split(':')[0] + ' host://' + tunnelHost +
' # from tunnel';
return hostHeader ? hostHeader + '\n' + tunnelHost : tunnelHost;
return joinRules(hostHeader, tunnelHost);
}
return hostHeader;
}
Expand Down

0 comments on commit 8c1859a

Please sign in to comment.