Skip to content

Commit

Permalink
Fixed a potential '//' at the end of the path of a resource + Added t…
Browse files Browse the repository at this point in the history
…he 'DAV' header with the values '1,2' => class 1 + 2 supported (RFC)
  • Loading branch information
AdrienCastex committed Jun 9, 2017
1 parent 3bc3f07 commit 27abc4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/server/MethodCallArgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var MethodCallArgs = (function () {
}
MethodCallArgs.create = function (server, request, response, callback) {
var mca = new MethodCallArgs(server, request, response, null, null);
response.setHeader('DAV', '1,2');
mca.askForAuthentication(false, function (e) {
if (e) {
callback(e, mca);
Expand Down Expand Up @@ -141,7 +142,7 @@ var MethodCallArgs = (function () {
if (uri === void 0) { uri = null; }
if (!uri)
uri = this.uri;
return this.prefixUri() + uri.replace(/\/\//g, '/');
return (this.prefixUri() + uri).replace(/([^:])\/\//g, '$1/');
};
MethodCallArgs.prototype.prefixUri = function () {
return 'http://' + this.host.replace('/', '');
Expand Down
3 changes: 2 additions & 1 deletion src/server/MethodCallArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class MethodCallArgs
callback : (error : Error, mca : MethodCallArgs) => void)
{
const mca = new MethodCallArgs(server, request, response, null, null);
response.setHeader('DAV', '1,2');

mca.askForAuthentication(false, (e) => {
if(e)
Expand Down Expand Up @@ -208,7 +209,7 @@ export class MethodCallArgs
if(!uri)
uri = this.uri;

return this.prefixUri() + uri.replace(/\/\//g, '/');
return (this.prefixUri() + uri).replace(/([^:])\/\//g, '$1/');
}

prefixUri()
Expand Down

0 comments on commit 27abc4e

Please sign in to comment.