Skip to content

Commit

Permalink
Cleaned the code
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jul 10, 2017
1 parent 03105d9 commit 50782df
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion examples/v2/customMethod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ server.method('TRACE', {
const nbPaths = wctx.requested.path.paths.length;
const method = wctx.headers.find('trace-method', '*').toLowerCase();
const separator = wctx.headers.find('trace-separator', '\r\n');
const iDepth = parseInt(wctx.headers.find('trace-depth', 'infinity').toLowerCase());
const iDepth = parseInt(wctx.headers.find('trace-depth', 'infinity').toLowerCase(), 10);
const depth = isNaN(iDepth) ? -1 : iDepth;
wctx.setCode(webdav.HTTPCodes.OK);

Expand Down
6 changes: 3 additions & 3 deletions src/server/commands/Propfind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ export function method(arg : MethodCallArgs, callback)
const prop = propstatError.ele('D:prop');
propstatError.ele('D:status').add(propstatStatus(HTTPCodes.NotFound));

for(let i = 0; i < reqBody.leftElements.length; ++i)
if(reqBody.leftElements[i])
prop.ele(reqBody.leftElements[i].name);
for(const el of reqBody.leftElements)
if(el)
prop.ele(el.name);
}
callback();
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/commands/Proppatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function method(arg : MethodCallArgs, callback)
arg.invokeEvent(eventName, r, el)
notify(el, e)
})
.done(() => finalize())
.done((_) => finalize())
})
}

Expand Down
6 changes: 3 additions & 3 deletions src/server/v2/commands/Propfind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ export default class implements HTTPMethod
const prop = propstatError.ele('D:prop');
propstatError.ele('D:status').add(propstatStatus(HTTPCodes.NotFound));

for(let i = 0; i < reqBody.leftElements.length; ++i)
if(reqBody.leftElements[i])
prop.ele(reqBody.leftElements[i].name);
for(const el of reqBody.leftElements)
if(el)
prop.ele(el.name);
}
callback();
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/v2/commands/Proppatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default class implements HTTPMethod
if(el.type === 'element')
notify(el, e)
})
.done(() => finalize())
.done((_) => finalize())
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/v2/commands/Unlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ export default class implements HTTPMethod
{
return !!type;
}
}
}
7 changes: 2 additions & 5 deletions src/server/v2/webDAVServer/BeforeAfter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { HTTPRequestContext, HTTPMethod } from '../WebDAVRequest'

export interface RequestListener
{
(ctx : HTTPRequestContext, next : () => void) : void
}
export type RequestListener = (ctx : HTTPRequestContext, next : () => void) => void;

function invokeBARequest(collection : RequestListener[], base : HTTPRequestContext, callback)
{
Expand Down Expand Up @@ -40,4 +37,4 @@ export function invokeBeforeRequest(base : HTTPRequestContext, callback)
export function invokeAfterRequest(base : HTTPRequestContext, callback)
{
invokeBARequest(this.afterManagers, base, callback);
}
}
6 changes: 1 addition & 5 deletions src/server/v2/webDAVServer/WebDAVServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { WebDAVServerOptions, setDefaultServerOptions } from '../WebDAVServerOptions'
import { HTTPRequestContext, ExternalRequestContext, RequestContextExternalOptions, RequestContext } from '../RequestContext'
import { WebDAVServerOptions, setDefaultServerOptions } from '../WebDAVServerOptions'
import { HTTPCodes, HTTPMethod } from '../WebDAVRequest'
import { HTTPAuthentication } from '../../../user/v2/authentication/HTTPAuthentication'
import { PrivilegeManager } from '../../../user/v2/privilege/PrivilegeManager'
Expand Down Expand Up @@ -241,10 +241,6 @@ export class WebDAVServer
};
}





onUnknownMethod(unknownMethod : HTTPMethod)
{
this.unknownMethod = unknownMethod;
Expand Down

0 comments on commit 50782df

Please sign in to comment.