From a46ccf72cef30eccf4cb3f9cdea9c461bb44f8b2 Mon Sep 17 00:00:00 2001 From: Caleb Mabry Date: Fri, 15 Jul 2022 00:44:10 -0400 Subject: Resolving issue with name display and encoding issue --- webAO/utils/__tests__/paths.test.ts | 13 +++++++++++++ webAO/utils/paths.ts | 1 + 2 files changed, 14 insertions(+) create mode 100644 webAO/utils/__tests__/paths.test.ts create mode 100644 webAO/utils/paths.ts (limited to 'webAO/utils') diff --git a/webAO/utils/__tests__/paths.test.ts b/webAO/utils/__tests__/paths.test.ts new file mode 100644 index 0000000..4f41d09 --- /dev/null +++ b/webAO/utils/__tests__/paths.test.ts @@ -0,0 +1,13 @@ +import {getFilenameFromPath} from '../paths' +jest.mock('../fileExists') + +describe('getFilenameFromPath', () => { + const EXAMPLE_PATH = "localhost/stoneddiscord/assets.png" + it('Should get the last value from a path', async () => { + const actual = getFilenameFromPath(EXAMPLE_PATH); + const expected = 'assets.png'; + expect(actual).toBe(expected); + }); +}) + + diff --git a/webAO/utils/paths.ts b/webAO/utils/paths.ts new file mode 100644 index 0000000..f4284b6 --- /dev/null +++ b/webAO/utils/paths.ts @@ -0,0 +1 @@ +export const getFilenameFromPath = (path: string) => path.substring(path.lastIndexOf('/') + 1) -- cgit