@@ -27,6 +27,11 @@ class CoCreateFileSystem {
27
27
28
28
async send ( req , res , crud , organization , valideUrl ) {
29
29
try {
30
+ if ( ! organization ) {
31
+ let hostNotFound = await getDefaultFile ( '/hostNotFound.html' )
32
+ return sendResponse ( hostNotFound . object [ 0 ] . src , 404 , { 'Content-Type' : 'text/html' } )
33
+ }
34
+
30
35
const organization_id = organization . _id
31
36
const hostname = valideUrl . hostname ;
32
37
@@ -56,19 +61,49 @@ class CoCreateFileSystem {
56
61
return sendResponse ( balanceFalse . object [ 0 ] . src , 403 , { 'Content-Type' : 'text/html' , 'Account-Balance' : 'false' , 'storage' : organization . storage } )
57
62
}
58
63
64
+ let lastIndex = pathname . lastIndexOf ( '/' ) ;
65
+ let wildcardPath = pathname . substring ( 0 , lastIndex + 1 ) ;
66
+ let wildcard = pathname . substring ( lastIndex + 1 ) ;
67
+
68
+ if ( wildcard . includes ( '.' ) ) {
69
+ let fileLastIndex = wildcard . lastIndexOf ( '.' ) ;
70
+ let fileExtension = wildcard . substring ( fileLastIndex ) ; // Get extension
71
+ wildcard = wildcardPath + '*' + fileExtension ; // Create wildcard for file name
72
+ } else {
73
+ wildcard = wildcardPath + '*' ; // Append '*' if it's just a path or folder
74
+ }
75
+
76
+ // console.log("Wildcard: ", wildcard);
77
+
59
78
let data = {
60
79
method : 'object.read' ,
61
80
array : 'files' ,
62
81
$filter : {
63
82
query : [
64
83
{ key : "host" , value : [ hostname , '*' ] , operator : "$in" } ,
65
- { key : "pathname" , value : pathname , operator : "$eq" }
84
+ { key : "pathname" , value : pathname , operator : "$eq" } ,
85
+ // { key: "pathname", value: wildcard, operator: "$eq", logicalOperator: "or" }
66
86
] ,
67
87
limit : 1
68
88
} ,
69
89
organization_id
70
90
}
71
91
92
+ if ( organization . fileSystem ) {
93
+ let fileSystem = organization . fileSystem . find ( element => element . name === hostname )
94
+ for ( let i = 0 ; i < fileSystem ; i ++ ) {
95
+ if ( fileSystem [ i ] . name === hostname ) {
96
+ if ( fileSystem [ i ] . storage )
97
+ data . storage = fileSystem [ i ] . storage
98
+ if ( fileSystem [ i ] . database )
99
+ data . database = fileSystem [ i ] . database
100
+ if ( fileSystem [ i ] . array )
101
+ data . array = fileSystem [ i ] . array
102
+ break
103
+ }
104
+ }
105
+ }
106
+
72
107
let file
73
108
if ( pathname . startsWith ( '/dist' ) || pathname . startsWith ( '/admin' ) || [ '/403.html' , '/404.html' , '/offline.html' , '/manifest.webmanifest' , '/service-worker.js' ] . includes ( pathname ) )
74
109
file = await getDefaultFile ( pathname )
0 commit comments