1// Flags: --expose-internals 2'use strict'; 3require('../common'); 4const assert = require('node:assert'); 5const path = require('node:path'); 6const { extname } = require('node:internal/modules/esm/get_format'); 7const { fileURLToPath } = require('node:url'); 8 9[ 10 'file:///c:/path/to/file', 11 'file:///c:/path/to/file.ext', 12 'file:///c:/path.to/file.ext', 13 'file:///c:/path.to/file', 14 'file:///c:/path.to/.file', 15 'file:///c:/path.to/.file.ext', 16 'file:///c:/path/to/f.ext', 17 'file:///c:/path/to/..ext', 18 'file:///c:/path/to/..', 19 'file:///c:/file', 20 'file:///c:/file.ext', 21 'file:///c:/.file', 22 'file:///c:/.file.ext', 23].forEach((input) => { 24 const inputAsURL = new URL(input); 25 const inputAsPath = fileURLToPath(inputAsURL); 26 assert.strictEqual(extname(inputAsURL), path.extname(inputAsPath)); 27}); 28