Skip to content

Commit

Permalink
process other request method path
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Jan 4, 2020
1 parent 24ed4a0 commit dd83685
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions worker/dist/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
6 changes: 6 additions & 0 deletions worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit dd83685

Please sign in to comment.