Skip to content

Commit dd180c1

Browse files
committed
test: path to file url
1 parent 068a171 commit dd180c1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

electron/main/electron-next/__tests__/path-to-file-url.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ describe('path-to-file-url', () => {
1313
});
1414

1515
describe('#pathToFileURL', () => {
16-
it('...', async () => {
16+
it('returns absolute file url to directory path joined with file path', async () => {
1717
expect(
1818
pathToFileURL({
1919
dirPath: '/a/b/',
20-
filePath: '/a/b/c.html',
20+
filePath: 'c.html',
2121
})
22-
).toBe(true);
22+
).toEqual('file:///a/b/c.html');
2323
});
2424
});
2525
});

electron/main/electron-next/path-to-file-url.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import path from 'node:path';
22
import url from 'node:url';
33

44
/**
5-
* Converts a file path to an absolute file URL.
6-
* Example: '/path/to/file.txt' -> 'file:///path/to/file.txt'
5+
* Converts a relative file path to an absolute file URL.
6+
* Example: 'file.txt' -> 'file:///path/to/file.txt'
77
*/
88
export const pathToFileURL = (options: {
9+
/**
10+
* The directory path to resolve the file path against.
11+
*/
912
dirPath: string;
13+
/**
14+
* The relative file path to convert to a file URL.
15+
*/
1016
filePath: string;
1117
}): string => {
1218
const { dirPath, filePath } = options;

0 commit comments

Comments
 (0)