Skip to content

Commit 1bcd0c7

Browse files
committed
#246: improve merging of same-service, same-hostname-path proxy configuration part 2
1 parent ff25d8d commit 1bcd0c7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugins/proxy/lib/utils.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,17 @@ exports.getProxyRunner = (project, files) => ({
9999
* Helper to get the trafix rule
100100
*/
101101
exports.getRule = rule => {
102+
// we do this so getRule is backwards campatible with the older rule.host
103+
const host = rule.hostname ?? rule.host;
104+
102105
// Start with the rule we can assume
103-
const hostRegex = rule.host.replace(new RegExp('\\*', 'g'), '{wildcard:[a-z0-9-]+}');
106+
const hostRegex = host.replace(new RegExp('\\*', 'g'), '{wildcard:[a-z0-9-]+}');
104107
const rules = [`HostRegexp(\`${hostRegex}\`)`];
108+
105109
// Add in the path prefix if we can
106110
if (rule.pathname.length > 1) rules.push(`PathPrefix(\`${rule.pathname}\`)`);
111+
112+
// return
107113
return rules.join(' && ');
108114
};
109115

0 commit comments

Comments
 (0)