Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ Site.prototype.deploy = function (travisTokenVar) {
let repoSlug = process.env.TRAVIS_REPO_SLUG;
if (options.repo) {
// Extract repo slug from user-specified repo URL so that we can include the access token
const repoSlugRegex = /github\.com[:/]([\w-]+\/[\w-]+)\.git/;
const repoSlugRegex = /github\.com[:/]([\w-]+\/[\w-.]+)\.git$/;
const repoSlugMatch = repoSlugRegex.exec(options.repo);
if (!repoSlugMatch) {
reject(new Error('-t/--travis expects a GitHub repository.\n'
Expand Down
17 changes: 17 additions & 0 deletions test/unit/Site.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,23 @@ describe('Site deploy with Travis', () => {
.toEqual(`https://${process.env.GITHUB_TOKEN}@github.com/USER/REPO.git`);
});

test('Site deploy -t/--travis deploys to correct repo when .git is in repo name', async () => {
process.env.TRAVIS = true;
process.env.GITHUB_TOKEN = 'githubToken';
process.env.TRAVIS_REPO_SLUG = 'TRAVIS_USER/TRAVIS_REPO.github.io';

const json = {
'src/template/page.ejs': PAGE_EJS,
'site.json': SITE_JSON_DEFAULT,
_site: {},
};
fs.vol.fromJSON(json, '');
const site = new Site('./', '_site');
await site.deploy(true);
expect(ghpages.options.repo)
.toEqual(`https://${process.env.GITHUB_TOKEN}@github.com/TRAVIS_USER/TRAVIS_REPO.github.io.git`);
});

test('Site deploy -t/--travis should not deploy if not in Travis', async () => {
const json = {
'src/template/page.ejs': PAGE_EJS,
Expand Down