mirror of
https://github.com/flarum/framework.git
synced 2024-12-01 14:20:47 +08:00
68c0cdb1a9
One params object is passed, and then route params are extracted into the route and the rest are appended as query params.
25 lines
552 B
JavaScript
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;
|