Hi all, Please find a patch that allows the user to define some behaviour for files when downloading.
diff --git a/modules/suggest-file-name.js b/modules/suggest-file-name.js index df36d4e..48e448c 100644 --- a/modules/suggest-file-name.js +++ b/modules/suggest-file-name.js @@ -268,9 +268,37 @@ function suggest_file_name(spec, extension) { return base_name; } +define_variable("download_replace_map", { }, + 'List of regular expressions associated with detail of how to \ +manipulate the file to be downloaded. For example: \ + \ + { \ + ".torrent$": { \ + "path": "/media-files/", \ + "transformer": function (filename) { \ + return filename.replace( /blah-/i, "" ); \ + } \ + } \ + } \ + \ +Will offer "/media-files" as the download directory and will strip \ +the string "blah-" from the name.'); + function suggest_save_path_from_file_name(file_name, buffer) { var cwd = (buffer && buffer.cwd) || default_directory.path; + var file = make_file(cwd); + for (let re in download_replace_map) { + if ( file_name.match( re ) ) { + if ( download_replace_map[ re ][ "path" ] ) { + file = make_file( download_replace_map[ re ][ "path" ] ); + } + + file_name = download_replace_map[ re ][ "transformer" ]( file_name ); + } + } + file.append(file_name); return file.path; } +
Cheers, Phil -- Philip Jackson web: http://www.shellarchive.co.uk
_______________________________________________ Conkeror mailing list Conkeror@mozdev.org https://www.mozdev.org/mailman/listinfo/conkeror