Skip to content

Commit

Permalink
fix(create-app): support github url has trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Aug 16, 2022
1 parent 5061167 commit d4085d1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/create-next-app/helpers/examples.ts
Expand Up @@ -25,9 +25,15 @@ export async function getRepoInfo(
const [, username, name, t, _branch, ...file] = url.pathname.split('/')
const filePath = examplePath ? examplePath.replace(/^\//, '') : file.join('/')

// Support repos whose entire purpose is to be a NextJS example, e.g.
// https://github.com/:username/:my-cool-nextjs-example-repo-name.
if (t === undefined) {
if (
// Support repos whose entire purpose is to be a NextJS example, e.g.
// https://github.com/:username/:my-cool-nextjs-example-repo-name.
t === undefined ||
// Support GitHub URL that ends with a trailing slash, e.g.
// https://github.com/:username/:my-cool-nextjs-example-repo-name/
// In this case "t" will be an empty string while the next part "_branch" will be undefined
(t === '' && _branch === undefined)
) {
const infoResponse = await got(
`https://api.github.com/repos/${username}/${name}`
).catch((e) => e)
Expand Down

0 comments on commit d4085d1

Please sign in to comment.