client/api: fix working with UTF8 entity IDs
This commit is contained in:
parent
65119d69ab
commit
03a7bd0d5c
3 changed files with 16 additions and 10 deletions
|
@ -32,8 +32,8 @@ class Tag extends events.EventTarget {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get(id) {
|
static get(name) {
|
||||||
return api.get('/tag/' + id)
|
return api.get('/tag/' + encodeURIComponent(name))
|
||||||
.then(response => {
|
.then(response => {
|
||||||
return Promise.resolve(Tag.fromResponse(response));
|
return Promise.resolve(Tag.fromResponse(response));
|
||||||
}, response => {
|
}, response => {
|
||||||
|
@ -62,7 +62,7 @@ class Tag extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
let promise = this._origName ?
|
let promise = this._origName ?
|
||||||
api.put('/tag/' + this._origName, detail) :
|
api.put('/tag/' + encodeURIComponent(this._origName), detail) :
|
||||||
api.post('/tags', detail);
|
api.post('/tags', detail);
|
||||||
return promise
|
return promise
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -79,7 +79,8 @@ class Tag extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
merge(targetName) {
|
merge(targetName) {
|
||||||
return api.get('/tag/' + targetName).then(response => {
|
return api.get('/tag/' + encodeURIComponent(targetName))
|
||||||
|
.then(response => {
|
||||||
return api.post('/tag-merge/', {
|
return api.post('/tag-merge/', {
|
||||||
removeVersion: this._version,
|
removeVersion: this._version,
|
||||||
remove: this._origName,
|
remove: this._origName,
|
||||||
|
@ -103,7 +104,7 @@ class Tag extends events.EventTarget {
|
||||||
|
|
||||||
delete() {
|
delete() {
|
||||||
return api.delete(
|
return api.delete(
|
||||||
'/tag/' + this._origName,
|
'/tag/' + encodeURIComponent(this._origName),
|
||||||
{version: this._version})
|
{version: this._version})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.dispatchEvent(new CustomEvent('delete', {
|
this.dispatchEvent(new CustomEvent('delete', {
|
||||||
|
|
|
@ -44,7 +44,9 @@ class TagCategory extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
let promise = this._origName ?
|
let promise = this._origName ?
|
||||||
api.put('/tag-category/' + this._origName, detail) :
|
api.put(
|
||||||
|
'/tag-category/' + encodeURIComponent(this._origName),
|
||||||
|
detail) :
|
||||||
api.post('/tag-categories', detail);
|
api.post('/tag-categories', detail);
|
||||||
|
|
||||||
return promise
|
return promise
|
||||||
|
@ -63,7 +65,7 @@ class TagCategory extends events.EventTarget {
|
||||||
|
|
||||||
delete() {
|
delete() {
|
||||||
return api.delete(
|
return api.delete(
|
||||||
'/tag-category/' + this._origName,
|
'/tag-category/' + encodeURIComponent(this._origName),
|
||||||
{version: this._version})
|
{version: this._version})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.dispatchEvent(new CustomEvent('delete', {
|
this.dispatchEvent(new CustomEvent('delete', {
|
||||||
|
|
|
@ -40,7 +40,7 @@ class User extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
static get(name) {
|
static get(name) {
|
||||||
return api.get('/user/' + name)
|
return api.get('/user/' + encodeURIComponent(name))
|
||||||
.then(response => {
|
.then(response => {
|
||||||
return Promise.resolve(User.fromResponse(response));
|
return Promise.resolve(User.fromResponse(response));
|
||||||
}, response => {
|
}, response => {
|
||||||
|
@ -74,7 +74,10 @@ class User extends events.EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
let promise = this._orig._name ?
|
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);
|
api.post('/users', detail, files);
|
||||||
|
|
||||||
return promise
|
return promise
|
||||||
|
@ -93,7 +96,7 @@ class User extends events.EventTarget {
|
||||||
|
|
||||||
delete() {
|
delete() {
|
||||||
return api.delete(
|
return api.delete(
|
||||||
'/user/' + this._orig._name,
|
'/user/' + encodeURIComponent(this._orig._name),
|
||||||
{version: this._version})
|
{version: this._version})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.dispatchEvent(new CustomEvent('delete', {
|
this.dispatchEvent(new CustomEvent('delete', {
|
||||||
|
|
Loading…
Reference in a new issue