Skip to content
This repository was archived by the owner on Jul 19, 2021. It is now read-only.

Commit 9051994

Browse files
authored
Merge pull request #821 from maximevaillancourt/master
Prevent trailing slashes at the end of store URLs
2 parents a695b6a + 64dc140 commit 9051994

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/slate-env/__tests__/index.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,20 @@ describe('Slate Env', () => {
328328
);
329329
});
330330

331+
test('the store URL environment variable does not end with a trailing slash', () => {
332+
['shop1.myshopify.com', 'shop1.myshopify.com/'].forEach((value) => {
333+
setVars(
334+
Object.assign({}, TEST_ENV, {
335+
[config.get('env.keys.store')]: value,
336+
}),
337+
);
338+
const result = slateEnv.validate();
339+
expect(result.errors).toHaveLength(
340+
value === 'shop1.myshopify.com/' ? 1 : 0,
341+
);
342+
});
343+
});
344+
331345
test('the store API password environment variable is empty', () => {
332346
setVars(
333347
Object.assign({}, TEST_ENV, {

packages/slate-env/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ function _validateStore() {
116116
`${config.get('env.keys.store')} must be a valid .myshopify.com URL`,
117117
),
118118
);
119+
} else if (store.slice(-1) === '/') {
120+
errors.push(
121+
new Error(
122+
`${config.get('env.keys.store')} must not end with a trailing slash`,
123+
),
124+
);
119125
}
120126

121127
return errors;

0 commit comments

Comments
 (0)