Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/consts/src/regexs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,4 @@ export const CONTACT_LINK_REGEX = /^(mailto|tel|sms):.*$/i;
* because we have user objects with that in database.
* @type {RegExp}
*/
// TODO: @fnesveda [2022-08-15] revert to stricter regex /^[a-zA-Z0-9]{17}$/ once we properly delete user yZtyxMUADJHyInTIdl
export const APIFY_ID_REGEX = /[a-zA-Z0-9]{17}/;
export const APIFY_ID_REGEX = /^[a-zA-Z0-9]{17}$/;
11 changes: 10 additions & 1 deletion test/consts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,23 @@ describe('consts', () => {
const testingStrings = {
valid: ['S64xo2hmHBFHbqZQq', 'Z7rgePnfc04QHshc2'],
invalid: [
// Invalid length
// Too short
'Z7rgePnfc04QHshc',
// Too long
'Z7rgePnfc04QHshc2X',
'yZtyxMUADJHyInTIdl',
// Invalid chars
'_7rgePnfc04QHshc2',
'-7rgePnfc04QHshc2',
'~7rgePnfc04QHshc2',
'}7rgePnfc04QHshc2',
'(7rgePnfc04QHshc2',
// Valid 17-char ID embedded in a larger string (must be rejected by the anchored regex)
' S64xo2hmHBFHbqZQq',
'S64xo2hmHBFHbqZQq ',
'xS64xo2hmHBFHbqZQqx',
// Empty string
'',
],
};
testingStrings.valid.forEach((str) => {
Expand Down
Loading