* Returns the file extension from a URL. Should give similar result to * `require('node:path').extname(require('node:url').fileURLToPath(url))` * when used with a `file:` URL. * @param {URL} url * @returns {string}
(url)
| 115 | * @returns {string} |
| 116 | */ |
| 117 | function extname(url) { |
| 118 | const { pathname } = url; |
| 119 | for (let i = pathname.length - 1; i > 0; i--) { |
| 120 | switch (StringPrototypeCharCodeAt(pathname, i)) { |
| 121 | case SLASH_CODE: |
| 122 | return ''; |
| 123 | |
| 124 | case DOT_CODE: |
| 125 | return StringPrototypeCharCodeAt(pathname, i - 1) === SLASH_CODE ? '' : StringPrototypeSlice(pathname, i); |
| 126 | } |
| 127 | } |
| 128 | return ''; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Determine whether the given file URL is under a `node_modules` folder. |
no outgoing calls
no test coverage detected
searching dependent graphs…