File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ const validate = require('./validate')();
2727 *
2828 * @type {RegExp }
2929 */
30- const RESOURCE_PATH_RE = / ^ p r o j e c t s \/ ( [ ^ / ] * ) \/ d a t a b a s e s \/ ( [ ^ / ] * ) (?: \/ d o c u m e n t s \/ ) ? ( .* ) $ / ;
30+ const RESOURCE_PATH_RE =
31+ // Note: [\s\S] matches all characters including newlines.
32+ / ^ p r o j e c t s \/ ( [ ^ / ] * ) \/ d a t a b a s e s \/ ( [ ^ / ] * ) (?: \/ d o c u m e n t s \/ ) ? ( [ \s \S ] * ) $ / ;
3133
3234/*!
3335 * A regular expression to verify whether a field name can be passed to the
@@ -295,6 +297,7 @@ class ResourcePath extends Path {
295297 get databaseId ( ) {
296298 return this . _databaseId ;
297299 }
300+
298301 /**
299302 * Returns true if the given string can be used as a relative or absolute
300303 * resource path.
Original file line number Diff line number Diff line change @@ -61,6 +61,13 @@ describe('ResourcePath', function() {
6161 ) ;
6262 } , / R e s o u r c e n a m e ' p r o j e c t s \/ p r o j e c t \/ d a t a b a s e s ' i s n o t v a l i d \. / ) ;
6363 } ) ;
64+
65+ it ( 'accepts newlines' , function ( ) {
66+ const path = ResourcePath . fromSlashSeparatedString (
67+ `${ DATABASE_ROOT } /documents/foo\nbar`
68+ ) ;
69+ assert . equal ( path . formattedName , `${ DATABASE_ROOT } /documents/foo\nbar` ) ;
70+ } ) ;
6471} ) ;
6572
6673describe ( 'FieldPath' , function ( ) {
You can’t perform that action at this time.
0 commit comments