Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.mdns.eu/nextcloud/passwords-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Classes/EnhancedApi.js2
-rw-r--r--src/Classes/SimpleApi.js20
2 files changed, 18 insertions, 4 deletions
diff --git a/src/Classes/EnhancedApi.js b/src/Classes/EnhancedApi.js
index 03c5a0d..1de0963 100644
--- a/src/Classes/EnhancedApi.js
+++ b/src/Classes/EnhancedApi.js
@@ -883,7 +883,7 @@ export default class EnhancedApi extends SimpleApi {
if(password.customFields) {
password.customFields = JSON.parse(password.customFields);
} else {
- password.customFields = {};
+ password.customFields = [];
}
diff --git a/src/Classes/SimpleApi.js b/src/Classes/SimpleApi.js
index 37361da..51e14e3 100644
--- a/src/Classes/SimpleApi.js
+++ b/src/Classes/SimpleApi.js
@@ -550,6 +550,7 @@ export default class SimpleApi {
* @returns {Promise}
*/
getAvatar(user, size = 32) {
+ user = encodeURIComponent(user);
return this._sendRequest(['service.avatar', {user, size}], null, 'GET', 'image/png');
}
@@ -561,6 +562,7 @@ export default class SimpleApi {
* @returns {*}
*/
getAvatarUrl(user, size = 32) {
+ user = encodeURIComponent(user);
return this._config.apiUrl + this.processUrl(this._paths['service.avatar'], {user, size});
}
@@ -573,6 +575,7 @@ export default class SimpleApi {
*/
getFavicon(domain, size = 32) {
if(domain === null || domain.length === 0) domain = 'default';
+ domain = encodeURIComponent(domain);
return this._sendRequest(['service.favicon', {domain, size}], null, 'GET', 'image/png');
}
@@ -585,6 +588,7 @@ export default class SimpleApi {
*/
getFaviconUrl(domain, size = 32) {
if(domain === null || domain.length === 0) domain = 'default';
+ domain = encodeURIComponent(domain);
return this._config.apiUrl + this.processUrl(this._paths['service.favicon'], {domain, size});
}
@@ -599,6 +603,7 @@ export default class SimpleApi {
*/
getPreview(domain, view = 'desktop', width = '640', height = '360...') {
if(domain === null || domain.length === 0) domain = 'default';
+ domain = encodeURIComponent(domain);
return this._sendRequest(
['service.preview', {domain, view, width, height}],
null,
@@ -618,6 +623,7 @@ export default class SimpleApi {
*/
getPreviewUrl(domain, view = 'desktop', width = '640', height = '360...') {
if(domain === null || domain.length === 0) domain = 'default';
+ domain = encodeURIComponent(domain);
return this._config.apiUrl + this.processUrl(
this._paths['service.preview'],
{domain, view, width, height}
@@ -738,13 +744,14 @@ export default class SimpleApi {
* @param data
* @param method
* @param dataType
+ * @param requestOptions
* @returns {Promise}
* @private
*/
- async _sendRequest(path, data = null, method = null, dataType = 'application/json') {
+ async _sendRequest(path, data = null, method = null, dataType = 'application/json', requestOptions = {}) {
if(!this._enabled) throw new Error('API not authorized');
let url = this._getRequestUrl(path),
- options = this._getRequestOptions(method, data, dataType),
+ options = this._getRequestOptions(method, data, dataType, requestOptions),
response = await this._executeRequest(url, options),
contentType = response.headers.get('content-type');
@@ -766,10 +773,11 @@ export default class SimpleApi {
* @param method
* @param data
* @param dataType
+ * @param requestOptions
* @returns {{method: *, headers: Headers, credentials: string}}
* @private
*/
- _getRequestOptions(method, data, dataType) {
+ _getRequestOptions(method, data, dataType, requestOptions) {
if(method === null || method === 'GET') method = data === null ? 'GET':'POST';
let headers = new Headers();
@@ -785,6 +793,12 @@ export default class SimpleApi {
options.body = JSON.stringify(data);
}
+ for(let key in requestOptions) {
+ if(!options.hasOwnProperty(key) && requestOptions.hasOwnProperty(key)) {
+ options[key] = requestOptions[key];
+ }
+ }
+
return options;
}