diff --git a/types/file-url/file-url-tests.ts b/types/file-url/file-url-tests.ts index e47cd737cb..463545b49f 100644 --- a/types/file-url/file-url-tests.ts +++ b/types/file-url/file-url-tests.ts @@ -1,10 +1,13 @@ import fileUrl = require("file-url"); -// Copied from https://github.com/sindresorhus/file-url/blob/14c7a69ae3798f50b3a4a21823c86e10b38160fe/readme.md - +// from https://raw.githubusercontent.com/sindresorhus/file-url/df60ecfe08f9844569c794e92ecc2c53d1dd298d/readme.md fileUrl('unicorn.jpg'); -//=> 'file:///Users/sindresorhus/dev/file-url/unicorn.jpg' +// => 'file:///Users/sindresorhus/dev/file-url/unicorn.jpg' fileUrl('/Users/pony/pics/unicorn.jpg'); -//=> 'file:///Users/pony/pics/unicorn.jpg' +// => 'file:///Users/pony/pics/unicorn.jpg' + +// passing {resolve: false} will make it not call path.resolve() on the path +fileUrl('unicorn.jpg', {resolve: false}); +// => 'file:///unicorn.jpg' diff --git a/types/file-url/index.d.ts b/types/file-url/index.d.ts index 1df68f6dbc..0772a16e38 100644 --- a/types/file-url/index.d.ts +++ b/types/file-url/index.d.ts @@ -1,12 +1,31 @@ -// Type definitions for file-url v1.0.1 +// Type definitions for file-url 2.0 // Project: https://github.com/sindresorhus/file-url -// Definitions by: MEDIA CHECK s.r.o. +// Definitions by: coderslagoon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/* + Original typings for 1.0 were provided by + "MEDIA CHECK s.r.o. ", + Did not pass the tslint check, hence mentioning it here. +*/ + +/** + * Options for the fileUrl() API. + */ +interface FileUrlOptions { + /** + * Passing false will make it not call path.resolve() on the path. + */ + resolve?: boolean; +} + /** * Convert a path to a file URL. + * @param path File path to convert. + * @param options Options to use. + * @return File URL. */ -declare function fileUrl(path:string):string; +declare function fileUrl(path: string, options?: FileUrlOptions): string; /** * Convert a path to a file URL. diff --git a/types/file-url/tslint.json b/types/file-url/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/file-url/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }