Skip to content

Commit 1525e63

Browse files
committed
feat(Util): add getExtension and getFile util methods to parse path
1 parent 3b269a0 commit 1525e63

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Util.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,21 @@ export async function fetch(input: RequestInfo | URL, init?: RequestInit): Promi
272272
}
273273

274274
/**
275-
* Extension parser
275+
* Get Extension part from path
276276
* @param path path to parse
277277
* @returns the extension
278278
*/
279-
export function parseExtension(path: string): string {
279+
export function getExtension(path: string): string {
280280
const dot = path.lastIndexOf('.');
281281
const ext = dot >= 0 && dot > path.lastIndexOf('/') ? path.substring(dot) : '';
282282
return ext;
283283
}
284+
285+
/**
286+
* Get File part from path
287+
* @param path path to parse
288+
* @returns the file name
289+
*/
290+
export function getFile(path: string): string {
291+
return path.substring(path.lastIndexOf('/') + 1);
292+
}

0 commit comments

Comments
 (0)