Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
fix: support email address in path
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsadhu committed May 11, 2021
1 parent 5684cea commit 93e2aa0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Joi = require('joi');

const file = Joi.string()
.label('entrypoint filename')
.regex(/^[a-zA-Z0-9/._-]+\.(js|jsx|css|ts|tsx)$/)
.regex(/^[a-zA-Z0-9@/._-]+\.(js|jsx|css|ts|tsx)$/)
.lowercase()
.trim()
.required();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
"@asset-pipe/dev-middleware": "^2.0.8",
"@asset-pipe/js-writer": "^2.0.4",
"@metrics/client": "^2.5.0",
"JSONStream": "^1.3.5",
"abslog": "^2.4.0",
"boom": "^7.3.0",
"commander": "^4.1.0",
"is-stream": "^2.0.0",
"joi": "^14.3.1",
"JSONStream": "^1.3.5",
"ow": "^0.15.0",
"request": "^2.88.0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/unit/__snapshots__/main.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`publishAssets(tag, entrypoints) - files array must contain .css or .js
"two"
]

[1] "entrypoint filename" with value "one" fails to match the required pattern: /^[a-zA-Z0-9/._-]+\\.(js|jsx|css|ts|tsx)$/[0m]
[1] "entrypoint filename" with value "one" fails to match the required pattern: /^[a-zA-Z0-9@/._-]+\\.(js|jsx|css|ts|tsx)$/[0m]
`;

exports[`publishAssets(tag, entrypoints) - files array must only contain strings 1`] = `
Expand Down
2 changes: 1 addition & 1 deletion test/unit/__snapshots__/schemas.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`file schema does not allow for non .js/.css/.ts/.tsx file extensions 1`] = `[ValidationError: "entrypoint filename" with value "index.json" fails to match the required pattern: /^[a-zA-Z0-9/._-]+\\.(js|jsx|css|ts|tsx)$/]`;
exports[`file schema does not allow for non .js/.css/.ts/.tsx file extensions 1`] = `[ValidationError: "entrypoint filename" with value "index.json" fails to match the required pattern: /^[a-zA-Z0-9@/._-]+\\.(js|jsx|css|ts|tsx)$/]`;
5 changes: 5 additions & 0 deletions test/unit/schemas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ test('file schema allows for absolute file paths', () => {
expect(result.error).toEqual(null);
});

test('file schema allows for email address in path', () => {
const result = Joi.validate('/path/[email protected]/index.js', schemas.file);
expect(result.error).toEqual(null);
});

test('hash schema', () => {
const hash = 'a1b2c3a1b2c3';
const result = Joi.validate(hash, schemas.hash);
Expand Down

0 comments on commit 93e2aa0

Please sign in to comment.