diff --git a/client/js/models/tag.js b/client/js/models/tag.js index 78890aa8..676ec54e 100644 --- a/client/js/models/tag.js +++ b/client/js/models/tag.js @@ -32,8 +32,8 @@ class Tag extends events.EventTarget { return ret; } - static get(id) { - return api.get('/tag/' + id) + static get(name) { + return api.get('/tag/' + encodeURIComponent(name)) .then(response => { return Promise.resolve(Tag.fromResponse(response)); }, response => { @@ -62,7 +62,7 @@ class Tag extends events.EventTarget { } let promise = this._origName ? - api.put('/tag/' + this._origName, detail) : + api.put('/tag/' + encodeURIComponent(this._origName), detail) : api.post('/tags', detail); return promise .then(response => { @@ -79,7 +79,8 @@ class Tag extends events.EventTarget { } merge(targetName) { - return api.get('/tag/' + targetName).then(response => { + return api.get('/tag/' + encodeURIComponent(targetName)) + .then(response => { return api.post('/tag-merge/', { removeVersion: this._version, remove: this._origName, @@ -103,7 +104,7 @@ class Tag extends events.EventTarget { delete() { return api.delete( - '/tag/' + this._origName, + '/tag/' + encodeURIComponent(this._origName), {version: this._version}) .then(response => { this.dispatchEvent(new CustomEvent('delete', { diff --git a/client/js/models/tag_category.js b/client/js/models/tag_category.js index da881e58..2777ed11 100644 --- a/client/js/models/tag_category.js +++ b/client/js/models/tag_category.js @@ -44,7 +44,9 @@ class TagCategory extends events.EventTarget { } let promise = this._origName ? - api.put('/tag-category/' + this._origName, detail) : + api.put( + '/tag-category/' + encodeURIComponent(this._origName), + detail) : api.post('/tag-categories', detail); return promise @@ -63,7 +65,7 @@ class TagCategory extends events.EventTarget { delete() { return api.delete( - '/tag-category/' + this._origName, + '/tag-category/' + encodeURIComponent(this._origName), {version: this._version}) .then(response => { this.dispatchEvent(new CustomEvent('delete', { diff --git a/client/js/models/user.js b/client/js/models/user.js index fa5afd38..6836b0dc 100644 --- a/client/js/models/user.js +++ b/client/js/models/user.js @@ -40,7 +40,7 @@ class User extends events.EventTarget { } static get(name) { - return api.get('/user/' + name) + return api.get('/user/' + encodeURIComponent(name)) .then(response => { return Promise.resolve(User.fromResponse(response)); }, response => { @@ -74,7 +74,10 @@ class User extends events.EventTarget { } let promise = this._orig._name ? - api.put('/user/' + this._orig._name, detail, files) : + api.put( + '/user/' + encodeURIComponent(this._orig._name), + detail, + files) : api.post('/users', detail, files); return promise @@ -93,7 +96,7 @@ class User extends events.EventTarget { delete() { return api.delete( - '/user/' + this._orig._name, + '/user/' + encodeURIComponent(this._orig._name), {version: this._version}) .then(response => { this.dispatchEvent(new CustomEvent('delete', {