-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from shapehq/enhancement/filter-filenames
Ignores files starting with dot and residing in directory when posting PR
- Loading branch information
Showing
5 changed files
with
209 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getBaseFilename } from "@/common" | ||
|
||
test("It returns base filename for file in root", async () => { | ||
const result = getBaseFilename("foo.yml") | ||
expect(result).toEqual("foo") | ||
}) | ||
|
||
test("It returns base filename for file path including dot", async () => { | ||
const result = getBaseFilename("foo.bar.yml") | ||
expect(result).toEqual("foo.bar") | ||
}) | ||
|
||
test("It returns base filename for file in folder", async () => { | ||
const result = getBaseFilename("foo/bar.yml") | ||
expect(result).toEqual("bar") | ||
}) | ||
|
||
test("It returns base filename when file path starts with a slash", async () => { | ||
const result = getBaseFilename("/foo/bar.yml") | ||
expect(result).toEqual("bar") | ||
}) | ||
|
||
test("It returns base filename when file path does not contain an extension", async () => { | ||
const result = getBaseFilename("foo") | ||
expect(result).toEqual("foo") | ||
}) | ||
|
||
test("It returns empty string for the empty string", async () => { | ||
const result = getBaseFilename("") | ||
expect(result).toEqual("") | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function getBaseFilename(filePath: string): string { | ||
const filename = filePath.split("/").pop() || "" | ||
if (!filename.includes(".")) { | ||
return filename | ||
} | ||
return filename.split(".").slice(0, -1).join(".") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters