Skip to content

Commit 975049c

Browse files
vikaspotluri123acburdine
authored andcommitted
fix(start): properly print admin URLs for blogs in a subdir
1 parent 134d4e1 commit 975049c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/commands/start.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class StartCommand extends Command {
2222

2323
run(argv) {
2424
const ProcessManager = require('../process-manager');
25-
const url = require('url');
2625
const chalk = require('chalk');
2726

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

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

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

test/unit/commands/start-spec.js

+20
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,26 @@ describe('Unit: Commands > Start', function () {
208208
});
209209
});
210210

211+
it('is normally loud', function () {
212+
myInstance.config.get.withArgs('url').returns('https://my-amazing.site/blog');
213+
myInstance.process = {};
214+
const ui = {
215+
run: () => Promise.resolve(),
216+
listr: () => Promise.resolve(),
217+
log: sinon.stub()
218+
};
219+
const start = new StartCommand(ui, mySystem);
220+
const runCommandStub = sinon.stub(start, 'runCommand').resolves();
221+
return start.run({enable: false}).then(() => {
222+
expect(runCommandStub.calledOnce).to.be.true;
223+
expect(ui.log.calledTwice).to.be.true;
224+
expect(ui.log.args[0][0]).to.match(/You can access your publication at/);
225+
expect(ui.log.args[0][0]).to.include('https://my-amazing.site/blog');
226+
expect(ui.log.args[1][0]).to.match(/Your admin interface is located at/);
227+
expect(ui.log.args[1][0]).to.include('https://my-amazing.site/blog/ghost/');
228+
});
229+
});
230+
211231
it('shows custom admin url', function () {
212232
const oldArgv = process.argv;
213233
process.argv = ['', '', 'start']

0 commit comments

Comments
 (0)