|
1 | | -module.exports.uriToFilename = uriToFilename |
2 | | -module.exports.uriToRelativeFilename = uriToRelativeFilename |
3 | 1 | module.exports.getBaseUri = getBaseUri |
4 | 2 | module.exports.pathBasename = pathBasename |
5 | 3 | module.exports.getFullUri = getFullUri |
6 | 4 | module.exports.hasSuffix = hasSuffix |
7 | 5 | module.exports.serialize = serialize |
8 | 6 | module.exports.translate = translate |
9 | 7 | module.exports.stringToStream = stringToStream |
10 | | -module.exports.reqToPath = reqToPath |
11 | 8 | module.exports.debrack = debrack |
12 | 9 | module.exports.stripLineEndings = stripLineEndings |
13 | 10 | module.exports.fullUrlForReq = fullUrlForReq |
14 | 11 | module.exports.routeResolvedFile = routeResolvedFile |
15 | 12 | module.exports.getQuota = getQuota |
16 | 13 | module.exports.overQuota = overQuota |
17 | 14 |
|
18 | | -const fs = require('fs-extra') |
19 | 15 | const path = require('path') |
20 | 16 | const util = require('util') |
21 | 17 | const $rdf = require('rdflib') |
@@ -73,29 +69,6 @@ function debrack (s) { |
73 | 69 | return s.substring(1, s.length - 1) |
74 | 70 | } |
75 | 71 |
|
76 | | -function uriToFilename (uri, base) { |
77 | | - const decoded = uri.split('/').map(decodeURIComponent).join('/') |
78 | | - let filename = path.join(base, decoded) |
79 | | - // Make sure filename ends with '/' if filename exists and is a directory. |
80 | | - // TODO this sync operation can be avoided and can be left |
81 | | - // to do, to other components, see `ldp.get` |
82 | | - try { |
83 | | - const fileStats = fs.statSync(filename) |
84 | | - if (fileStats.isDirectory() && !filename.endsWith('/')) { |
85 | | - filename += '/' |
86 | | - } else if (fileStats.isFile() && filename.endsWith('/')) { |
87 | | - filename = filename.substr(0, filename.length - 1) |
88 | | - } |
89 | | - } catch (err) {} |
90 | | - return filename |
91 | | -} |
92 | | - |
93 | | -function uriToRelativeFilename (uri, base) { |
94 | | - const filename = uriToFilename(uri, base) |
95 | | - const relative = path.relative(base, filename) |
96 | | - return relative |
97 | | -} |
98 | | - |
99 | 72 | function getBaseUri (req) { |
100 | 73 | // Obtain the protocol from the configured server URI |
101 | 74 | // (in case the server is running behind a reverse proxy) |
@@ -221,12 +194,6 @@ function stripLineEndings (obj) { |
221 | 194 | return obj.replace(/(\r\n|\n|\r)/gm, '') |
222 | 195 | } |
223 | 196 |
|
224 | | -function reqToPath (req) { |
225 | | - const ldp = req.app.locals.ldp |
226 | | - const root = ldp.multiuser ? ldp.root + req.hostname + '/' : ldp.root |
227 | | - return uriToFilename(req.path, root) |
228 | | -} |
229 | | - |
230 | 197 | /** |
231 | 198 | * Adds a route that serves a static file from another Node module |
232 | 199 | */ |
|
0 commit comments