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

Commit

Permalink
Merge pull request #821 from maximevaillancourt/master
Browse files Browse the repository at this point in the history
Prevent trailing slashes at the end of store URLs
  • Loading branch information
t-kelly authored Oct 25, 2018
2 parents a695b6a + 64dc140 commit 9051994
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/slate-env/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,20 @@ describe('Slate Env', () => {
);
});

test('the store URL environment variable does not end with a trailing slash', () => {
['shop1.myshopify.com', 'shop1.myshopify.com/'].forEach((value) => {
setVars(
Object.assign({}, TEST_ENV, {
[config.get('env.keys.store')]: value,
}),
);
const result = slateEnv.validate();
expect(result.errors).toHaveLength(
value === 'shop1.myshopify.com/' ? 1 : 0,
);
});
});

test('the store API password environment variable is empty', () => {
setVars(
Object.assign({}, TEST_ENV, {
Expand Down
6 changes: 6 additions & 0 deletions packages/slate-env/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ function _validateStore() {
`${config.get('env.keys.store')} must be a valid .myshopify.com URL`,
),
);
} else if (store.slice(-1) === '/') {
errors.push(
new Error(
`${config.get('env.keys.store')} must not end with a trailing slash`,
),
);
}

return errors;
Expand Down

0 comments on commit 9051994

Please sign in to comment.