Your example can easily be dealt with using Node.js’s url module:
var URL = require('url').parse('site.com:8080/someFile.txt?attr=100');
console.log(URL.pathname.replace(/(^\/|\/$)/g,'')); // "someFile.txt"
However, this doesn’t work with Node.js’s exemplary URL (’cause it’s got more path).
By truncanting the complete path starting at its rightmost slash, it’ll yield the file name:
var URL = require('url').parse('http://user:[email protected]:8080/p/a/t/h?query=string#hash');
console.log(URL.pathname.substring(URL.pathname.lastIndexOf('/')+1)); // "h"
And if that idea is considered safe enough for the appliance, we can do it plain:
var file = url.substring(url.lastIndexOf('/')+1).replace(/((\?|#).*)?$/,'');
/* hashes and query strings ----^ */
someFile.txt?Kitty.jpgororder.json).http://