@@ -6,40 +6,12 @@ const getContentType = require('../utils').getContentType
66const HTTPError = require ( '../http-error' )
77const { stringToStream } = require ( '../utils' )
88
9- // TODO: ask alain a better way to get the suffix variables here
10- const RESERVED_SUFFIXES = [ '.acl' , '.meta' ]
11-
12- /**
13- * This function is used to make sure a resource or container which contains
14- * reserved suffixes for auxiliary documents cannot be created.
15- * @param {string } path - the uri to check for invalid suffixes
16- * @returns {boolean } true is fail - if the path contains reserved suffixes
17- */
18- function containsInvalidSuffixes ( path ) {
19- // if it is a container, no suffix so remove last slash
20- if ( path . endsWith ( '/' ) ) {
21- path = path . slice ( 0 , - 1 )
22- } else {
23- // this is a resource, so it either ends with an extension, or just text
24- const lastFullStop = path . lastIndexOf ( '.' )
25- if ( lastFullStop !== - 1 ) { // contains at least one full stop
26- path = path . slice ( 0 , lastFullStop )
27- }
28- }
29- return RESERVED_SUFFIXES . some ( suffix => path . includes ( suffix ) )
30- }
31-
329async function handler ( req , res , next ) {
3310 debug ( req . originalUrl )
3411 // deprecated kept for compatibility
3512 res . header ( 'MS-Author-Via' , 'SPARQL' ) // is this needed ?
3613 const contentType = req . get ( 'content-type' )
3714
38- // make sure the resource being created does not attempt invalid resource creation
39- if ( containsInvalidSuffixes ( req . url ) ) {
40- next ( new HTTPError ( 400 , `${ req . url } contained reserved suffixes in path` ) )
41- }
42-
4315 // check whether a folder or resource with same name exists
4416 try {
4517 const ldp = req . app . locals . ldp
0 commit comments