Skip to content

Commit 3cd2b4a

Browse files
committed
fix: Ensure we have a port number when adding the URL
1 parent 4926169 commit 3cd2b4a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/steps/getEnvVars.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ export async function getEnvVars(interactive, template, argDeploymentUsername, a
9595
if (!target.startsWith('http://') && !target.startsWith('https://')) {
9696
target = 'https://' + target;
9797
}
98+
99+
try {
100+
const url = new URL(target);
101+
if (!url.port) {
102+
url.port = '9925';
103+
}
104+
target = url.toString();
105+
} catch {
106+
// If it's not a valid URL yet, we'll let it be handled later or it will fail
107+
}
108+
98109
if (!target.endsWith('/')) {
99110
target = target + '/';
100111
}

lib/steps/getEnvVars.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('getEnvVars', () => {
4343
expect(result).toEqual({
4444
envVars: {
4545
username: 'testuser',
46-
target: 'https://testtarget/',
46+
target: 'https://testtarget:9925/',
4747
password: 'YOUR_CLUSTER_PASSWORD',
4848
},
4949
cancelled: false,
@@ -77,7 +77,7 @@ describe('getEnvVars', () => {
7777
expect(result).toEqual({
7878
envVars: {
7979
username: 'promptuser',
80-
target: 'https://prompttarget/',
80+
target: 'https://prompttarget:9925/',
8181
password: 'promptpassword',
8282
},
8383
cancelled: false,
@@ -147,7 +147,7 @@ describe('getEnvVars', () => {
147147

148148
const result = await getEnvVars(false, 'vanilla', argUsername, argTarget);
149149

150-
expect(result.envVars.target).toBe('https://example.com/');
150+
expect(result.envVars.target).toBe('https://example.com:9925/');
151151
process.env._HARPER_TEST_CLI = originalEnv;
152152
});
153153

@@ -159,7 +159,7 @@ describe('getEnvVars', () => {
159159

160160
const result = await getEnvVars(false, 'vanilla', argUsername, argTarget);
161161

162-
expect(result.envVars.target).toBe('http://example.com/');
162+
expect(result.envVars.target).toBe('http://example.com:9925/');
163163
process.env._HARPER_TEST_CLI = originalEnv;
164164
});
165165

@@ -171,7 +171,7 @@ describe('getEnvVars', () => {
171171

172172
const result = await getEnvVars(false, 'vanilla', argUsername, argTarget);
173173

174-
expect(result.envVars.target).toBe('https://example.com/');
174+
expect(result.envVars.target).toBe('https://example.com:9925/');
175175
process.env._HARPER_TEST_CLI = originalEnv;
176176
});
177177

0 commit comments

Comments
 (0)