From dd836857c3d691a5e41bded9bb2cdb1b64c39459 Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sat, 4 Jan 2020 22:34:50 +0800 Subject: [PATCH] process other request method path --- worker/dist/worker.js | 8 ++++++++ worker/index.js | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/worker/dist/worker.js b/worker/dist/worker.js index 99fe4719..f48c2268 100644 --- a/worker/dist/worker.js +++ b/worker/dist/worker.js @@ -509,6 +509,10 @@ self.props = { } = request; const rootId = request.searchParams.get('rootId') || self.props.default_root_id; + if (path.startsWith(`/${self.props.subdir}/`)) { + path = path.substr(self.props.subdir.length + 1); + } + if (path.substr(-1) === '/') { return new Response(JSON.stringify((await gd.listFolderByPath(path, rootId))), { headers: { @@ -548,6 +552,10 @@ self.props = { pathname: path } = request; + if (path.startsWith(`/${self.props.subdir}/`)) { + path = path.substr(self.props.subdir.length + 1); + } + if (path.substr(-1) === '/') { return new Response(null, { headers: { diff --git a/worker/index.js b/worker/index.js index 863b34cb..5c6e7f74 100644 --- a/worker/index.js +++ b/worker/index.js @@ -59,6 +59,9 @@ async function onGet(request) { async function onPost(request) { let { pathname: path } = request const rootId = request.searchParams.get('rootId') || self.props.default_root_id + if (path.startsWith(`/${self.props.subdir}/`)) { + path = path.substr(self.props.subdir.length + 1) + } if (path.substr(-1) === '/') { return new Response(JSON.stringify(await gd.listFolderByPath(path, rootId)), { headers: { @@ -91,6 +94,9 @@ async function onPost(request) { } async function onPut(request) { let { pathname: path } = request + if (path.startsWith(`/${self.props.subdir}/`)) { + path = path.substr(self.props.subdir.length + 1) + } if (path.substr(-1) === '/') { return new Response(null, { headers: {