@@ -1017,7 +1017,7 @@ Schema.prototype.path = function(path, obj) {
1017
1017
1018
1018
// subpaths?
1019
1019
return / \. \d + \. ? .* $ / . test ( path )
1020
- ? getPositionalPath ( this , path )
1020
+ ? getPositionalPath ( this , path , cleanPath )
1021
1021
: undefined ;
1022
1022
}
1023
1023
@@ -1634,7 +1634,7 @@ Schema.prototype.pathType = function(path) {
1634
1634
}
1635
1635
1636
1636
if ( / \. \d + \. | \. \d + $ / . test ( path ) ) {
1637
- return getPositionalPathType ( this , path ) ;
1637
+ return getPositionalPathType ( this , path , cleanPath ) ;
1638
1638
}
1639
1639
return 'adhocOrUndefined' ;
1640
1640
} ;
@@ -1678,7 +1678,7 @@ Schema.prototype.setupTimestamp = function(timestamps) {
1678
1678
* @api private
1679
1679
*/
1680
1680
1681
- function getPositionalPathType ( self , path ) {
1681
+ function getPositionalPathType ( self , path , cleanPath ) {
1682
1682
const subpaths = path . split ( / \. ( \d + ) \. | \. ( \d + ) $ / ) . filter ( Boolean ) ;
1683
1683
if ( subpaths . length < 2 ) {
1684
1684
return self . paths . hasOwnProperty ( subpaths [ 0 ] ) ?
@@ -1729,7 +1729,7 @@ function getPositionalPathType(self, path) {
1729
1729
val = val . schema . path ( subpath ) ;
1730
1730
}
1731
1731
1732
- self . subpaths [ path ] = val ;
1732
+ self . subpaths [ cleanPath ] = val ;
1733
1733
if ( val ) {
1734
1734
return 'real' ;
1735
1735
}
@@ -1744,9 +1744,9 @@ function getPositionalPathType(self, path) {
1744
1744
* ignore
1745
1745
*/
1746
1746
1747
- function getPositionalPath ( self , path ) {
1748
- getPositionalPathType ( self , path ) ;
1749
- return self . subpaths [ path ] ;
1747
+ function getPositionalPath ( self , path , cleanPath ) {
1748
+ getPositionalPathType ( self , path , cleanPath ) ;
1749
+ return self . subpaths [ cleanPath ] ;
1750
1750
}
1751
1751
1752
1752
/**
@@ -2638,6 +2638,9 @@ Schema.prototype._getSchema = function(path) {
2638
2638
// Re: gh-5628, because `schema.path()` doesn't take $ into account.
2639
2639
parts [ i ] = '0' ;
2640
2640
}
2641
+ if ( / ^ \d + $ / . test ( parts [ i ] ) ) {
2642
+ parts [ i ] = '$' ;
2643
+ }
2641
2644
}
2642
2645
return search ( parts , _this ) ;
2643
2646
} ;
0 commit comments