diff --git a/__tests__/util/guess-name.js b/__tests__/util/guess-name.js index a9115480a1..f7fc41be6d 100644 --- a/__tests__/util/guess-name.js +++ b/__tests__/util/guess-name.js @@ -24,6 +24,13 @@ const examples = [ 'awesome-name.tar.gz', ]; +const dotExamples = [ + 'awesomename/awesome.name', + 'awesomename/awesome.name.git', + 'awesomename/awesome.name.tar.gz', + 'awesomename/awesome.name.tar.bz2', +]; + describe('guessName', () => { for (const source of examples) { it(`guess name of ${source}`, () => { @@ -31,3 +38,11 @@ describe('guessName', () => { }); } }); + +describe('guessName dot examples', () => { + for (const source of dotExamples) { + it(`guess name of ${source}`, () => { + expect(guessName(source)).toBe('awesome.name'); + }); + } +}); diff --git a/src/util/guess-name.js b/src/util/guess-name.js index a922718412..88352c89df 100644 --- a/src/util/guess-name.js +++ b/src/util/guess-name.js @@ -4,7 +4,7 @@ import url from 'url'; function cleanup(name: string): string { name = name.replace(/-\d+\.\d+\.\d+/, ''); - return name.split('.')[0]; + return name.replace(/\.git$|\.zip$|\.tar\.gz$|\.tar\.bz2$/, ''); } function guessNameFallback(source: string): string {