Let’s say you have this URL:
http://wp.com/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp
and you want to get the filename, which is the jquery.js
part. To do so:
const url = 'http://wp.com/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp';
// Returns 'jquery.js?ver=1.12.4-wp'
const filenameQuerystring = url.split('/').pop();
// Returns 'jquery.js'
const filename = filenameQuerystring.split('?').shift();