mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 15:47:57 -05:00
15 lines
371 B
JavaScript
15 lines
371 B
JavaScript
|
const path = require('path')
|
||
|
/**
|
||
|
* get filename from url
|
||
|
* @param {string} urlStr the url
|
||
|
* @return {string} filename
|
||
|
* @example
|
||
|
* getFilenameFromUrl('https://sus.red/amogus.mid?verysus=true') // returns 'amogus.mid'
|
||
|
*/
|
||
|
function getFilenameFromUrl (urlStr) {
|
||
|
const url = new URL(urlStr)
|
||
|
return path.basename(url.pathname)
|
||
|
}
|
||
|
|
||
|
module.exports = getFilenameFromUrl
|