Skip to content

Commit

Permalink
Bug fix and replace the file path
Browse files Browse the repository at this point in the history
  • Loading branch information
lfades committed Jan 23, 2020
1 parent a7fe741 commit b26c0f0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/create-next-app/helpers/examples.ts
Expand Up @@ -18,12 +18,14 @@ export function getRepoInfo(
url: URL,
examplePath?: string
): RepoInfo | undefined {
const [, username, name, tree, _branch, ...path] = url.pathname.split('/')
const filePath = examplePath || path.join('/')
const [, username, name, t, _branch, ...file] = url.pathname.split('/')
const filePath = examplePath ? examplePath.replace(/^\//, '') : file.join('/')
// If examplePath is available, the branch name takes the entire path
const branch = examplePath ? _branch + path.join('/') : _branch
const branch = examplePath
? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}$`), '')
: _branch

if (username && name && branch && tree === 'tree') {
if (username && name && branch && t === 'tree') {
return { username, name, branch, filePath }
}
}
Expand Down

0 comments on commit b26c0f0

Please sign in to comment.