Skip to content

Commit 5d7ec67

Browse files
committed
refactor: address code review comments by moving regexp to constant
1 parent 0741366 commit 5d7ec67

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/schema.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const isPOJO = utils.isPOJO;
3737

3838
let id = 0;
3939

40+
const numberRE = /^\d+$/;
41+
4042
/**
4143
* Schema constructor.
4244
*
@@ -2638,7 +2640,7 @@ Schema.prototype._getSchema = function(path) {
26382640
// Re: gh-5628, because `schema.path()` doesn't take $ into account.
26392641
parts[i] = '0';
26402642
}
2641-
if (/^\d+$/.test(parts[i])) {
2643+
if (numberRE.test(parts[i])) {
26422644
parts[i] = '$';
26432645
}
26442646
}

0 commit comments

Comments
 (0)