0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/client/utils/ghost-paths.js
Robert Jackson 333beb2198 Make exports consitent.
Previously, the exports were somewhat random with some files declaring
local variables then immediately exporting them, and others simply
doing the work needed in the export itself.
2014-06-09 13:58:35 -04:00

31 lines
708 B
JavaScript

var makeRoute = function (root, args) {
var parts = Array.prototype.slice.call(args, 0).join('/'),
route = [root, parts].join('/');
if (route.slice(-1) !== '/') {
route += '/';
}
return route;
};
function ghostPaths() {
var path = window.location.pathname,
subdir = path.substr(0, path.search('/ghost/'));
return {
subdir: subdir,
adminRoot: subdir + '/ghost',
apiRoot: subdir + '/ghost/api/v0.1',
adminUrl: function () {
return makeRoute(this.adminRoot, arguments);
},
apiUrl: function () {
return makeRoute(this.apiRoot, arguments);
}
};
}
export default ghostPaths;