Skip to content

Commit

Permalink
Fix owncloud fromObject - fixes #129
Browse files Browse the repository at this point in the history
  • Loading branch information
perry-mitchell committed Dec 30, 2016
1 parent c741d8d commit c768bfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions source/classes/OwnCloudDatasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class OwnCloudDatasource extends WebDAVDatasource {
*/
constructor(owncloudURL, resourcePath, username, password) {
var urlLen = owncloudURL.length;
this._owncloudURL = owncloudURL;
this._owncloudPath = resourcePath;
owncloudURL = (owncloudURL[urlLen - 1] === "/") ? owncloudURL : owncloudURL + "/";
owncloudURL += "remote.php/webdav/";
super(owncloudURL, resourcePath, username, password);
Expand All @@ -30,9 +32,11 @@ class OwnCloudDatasource extends WebDAVDatasource {
* @returns {Object} An object describing the datasource
*/
toObject() {
return Object.assign(super.toObject(), {
type: "owncloud"
});
return {
type: "owncloud",
endpoint: this._owncloudURL,
path: this._owncloudPath
};
}

}
Expand All @@ -41,7 +45,7 @@ OwnCloudDatasource.fromObject = function fromObject(obj, hostCredentials) {
if (!hostCredentials) {
throw new Error("Credentials required for OwnCloudDatasource instantiation");
}
if (obj.type === "webdav") {
if (obj.type === "owncloud") {
return new OwnCloudDatasource(obj.endpoint, obj.path, hostCredentials.username, hostCredentials.password);
}
throw new Error(`Unknown or invalid type: ${obj.type}`);
Expand Down
4 changes: 2 additions & 2 deletions source/classes/WebDAVDatasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ class WebDAVDatasource extends TextDatasource {
* @returns {Object} An object describing the datasource
*/
toObject() {
return Object.assign(super.toObject(), {
return {
type: "webdav",
endpoint: this._endpoint,
path: this._path
});
};
}

}
Expand Down

0 comments on commit c768bfd

Please sign in to comment.