szurubooru/client/js/models/snapshot_list.js
rr- 7fa8593b0a client/general: improve URL escaping
Specifically, cater for /, + and % in URL components.
2016-09-04 02:07:22 +02:00

25 lines
721 B
JavaScript

'use strict';
const api = require('../api.js');
const AbstractList = require('./abstract_list.js');
const Snapshot = require('./snapshot.js');
class SnapshotList extends AbstractList {
static search(text, page, pageSize) {
const url =
`/snapshots/?query=${encodeURIComponent(text)}` +
`&page=${page}` +
`&pageSize=${pageSize}`;
return api.get(url).then(response => {
return Promise.resolve(Object.assign(
{},
response,
{results: SnapshotList.fromResponse(response.results)}));
});
}
}
SnapshotList._itemClass = Snapshot;
SnapshotList._itemName = 'snapshot';
module.exports = SnapshotList;