mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
Correct behaviour for trailing slashes
fixes #2741 - Extend HistoryLocation - Add trailing slash to path
This commit is contained in:
parent
ff0dc79546
commit
db4994e954
@ -2,6 +2,7 @@ import Resolver from 'ember/resolver';
|
||||
import initFixtures from 'ghost/fixtures/init';
|
||||
import {currentUser, injectCurrentUser} from 'ghost/initializers/current-user';
|
||||
import {registerNotifications, injectNotifications} from 'ghost/initializers/notifications';
|
||||
import registerTrailingLocationHistory from 'ghost/initializers/trailing-history';
|
||||
import 'ghost/utils/link-view';
|
||||
import 'ghost/utils/text-field';
|
||||
|
||||
@ -24,5 +25,6 @@ App.initializer(currentUser);
|
||||
App.initializer(injectCurrentUser);
|
||||
App.initializer(registerNotifications);
|
||||
App.initializer(injectNotifications);
|
||||
App.initializer(registerTrailingLocationHistory);
|
||||
|
||||
export default App;
|
||||
|
23
ghost/admin/initializers/trailing-history.js
Normal file
23
ghost/admin/initializers/trailing-history.js
Normal file
@ -0,0 +1,23 @@
|
||||
/*global Ember */
|
||||
|
||||
var trailingHistory = Ember.HistoryLocation.extend({
|
||||
setURL: function (path) {
|
||||
var state = this.getState();
|
||||
path = this.formatURL(path);
|
||||
path = path.replace(/\/?$/, '/');
|
||||
|
||||
if (state && state.path !== path) {
|
||||
this.pushState(path);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var registerTrailingLocationHistory = {
|
||||
name: 'registerTrailingLocationHistory',
|
||||
|
||||
initialize: function (container, application) {
|
||||
application.register('location:trailing-history', trailingHistory);
|
||||
}
|
||||
};
|
||||
|
||||
export default registerTrailingLocationHistory;
|
@ -4,7 +4,7 @@
|
||||
var Router = Ember.Router.extend();
|
||||
|
||||
Router.reopen({
|
||||
location: 'history', // use HTML5 History API instead of hash-tag based URLs
|
||||
location: 'trailing-history', // use HTML5 History API instead of hash-tag based URLs
|
||||
rootURL: '/ghost/ember/' // admin interface lives under sub-directory /ghost
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user