Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
fix #129 fall back to master
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Dec 19, 2018
1 parent 64d6acf commit cd37c79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
11 changes: 7 additions & 4 deletions src/html/fetch-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,25 @@ async function fetch(

// get required request parameters
const {
owner, repo, ref, path,
owner, repo, path,
} = request.params;

let { ref } = request.params;

// bail if a required parameter cannot be found
if (!owner) {
return bail(logger, 'Unknown owner, cannot fetch content');
}
if (!repo) {
return bail(logger, 'Unknown repo, cannot fetch content');
}
if (!ref) {
return bail(logger, 'Unknown ref, cannot fetch content');
}
if (!path) {
return bail(logger, 'Unknown path, cannot fetch content');
}
if (!ref) {
logger.warn(`Recoverable error: no ref given for ${repo}/${owner}.git${path}, falling back to master`);
ref = 'master';
}

const { REPO_RAW_ROOT: rootPath } = secrets;

Expand Down
10 changes: 0 additions & 10 deletions test/testFetchMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,6 @@ describe('Test invalid input', () => {
)).error);
});

it('Test for missing ref', async () => {
assert.equal((await fetch(
{},
{
request: { params: { repo: 'xdm', path: 'README.md', owner: 'adobe' } },
logger,
},
)).error, null);
});

it('Test for missing path', async () => {
assert.ok((await fetch(
{},
Expand Down

0 comments on commit cd37c79

Please sign in to comment.