Skip to content

Commit

Permalink
fix(start): properly print admin URLs for blogs in a subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
vikaspotluri123 authored and acburdine committed Jun 14, 2018
1 parent 134d4e1 commit 975049c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class StartCommand extends Command {

run(argv) {
const ProcessManager = require('../process-manager');
const url = require('url');
const chalk = require('chalk');

const instance = this.system.getInstance();
Expand Down Expand Up @@ -64,7 +63,8 @@ class StartCommand extends Command {
const isInstall = process.argv[2] === 'install';
let adminUrl = instance.config.get('admin.url') || instance.config.get('url');

adminUrl = url.resolve(adminUrl, '/ghost/');
// Strip the trailing slash and add the admin path
adminUrl = `${adminUrl.replace(/\/$/,'')}/ghost/`;

this.ui.log(`You can access your publication at ${chalk.cyan(instance.config.get('url'))}`, 'white');

Expand Down
20 changes: 20 additions & 0 deletions test/unit/commands/start-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@ describe('Unit: Commands > Start', function () {
});
});

it('is normally loud', function () {
myInstance.config.get.withArgs('url').returns('https://my-amazing.site/blog');
myInstance.process = {};
const ui = {
run: () => Promise.resolve(),
listr: () => Promise.resolve(),
log: sinon.stub()
};
const start = new StartCommand(ui, mySystem);
const runCommandStub = sinon.stub(start, 'runCommand').resolves();
return start.run({enable: false}).then(() => {
expect(runCommandStub.calledOnce).to.be.true;
expect(ui.log.calledTwice).to.be.true;
expect(ui.log.args[0][0]).to.match(/You can access your publication at/);
expect(ui.log.args[0][0]).to.include('https://my-amazing.site/blog');
expect(ui.log.args[1][0]).to.match(/Your admin interface is located at/);
expect(ui.log.args[1][0]).to.include('https://my-amazing.site/blog/ghost/');
});
});

it('shows custom admin url', function () {
const oldArgv = process.argv;
process.argv = ['', '', 'start']
Expand Down

0 comments on commit 975049c

Please sign in to comment.