client/api: fix working with UTF8 entity IDs

This commit is contained in:
rr- 2016-08-16 20:09:03 +02:00
parent 65119d69ab
commit 03a7bd0d5c
3 changed files with 16 additions and 10 deletions

View file

@ -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', {

View file

@ -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', {

View file

@ -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', {