framework/js/lib/utils/app.js
Toby Zerner 68c0cdb1a9 Combine route/query params in route construction
One params object is passed, and then route params are extracted into
the route and the rest are appended as query params.
2015-05-02 08:21:40 +09:30

25 lines
552 B
JavaScript

import ItemList from 'flarum/utils/item-list';
class App {
constructor() {
this.initializers = new ItemList();
this.cache = {};
}
boot() {
this.initializers.toArray().forEach((initializer) => initializer(this));
}
route(name, params) {
var url = this.routes[name][0].replace(/:([^\/]+)/g, function(m, t) {
var value = params[t];
delete params[t];
return value;
});
var queryString = m.route.buildQueryString(params);
return url+(queryString ? '?'+queryString : '');
}
}
export default App;