From dac2abf72a964c71f6ad3ab0c9efc025a92a5b2d Mon Sep 17 00:00:00 2001 From: zhuzhuor Date: Wed, 29 Jun 2022 14:33:54 -0700 Subject: [PATCH] Move the code of producing regex in command line into its own js file --- shared/produce_regex.js | 9 +++++++++ shared/urls.js | 20 -------------------- 2 files changed, 9 insertions(+), 20 deletions(-) create mode 100644 shared/produce_regex.js diff --git a/shared/produce_regex.js b/shared/produce_regex.js new file mode 100644 index 0000000..4fcb9fc --- /dev/null +++ b/shared/produce_regex.js @@ -0,0 +1,9 @@ +'use strict'; + +const shared_urls = require('../shared/urls'); + +const chrome_regex_list = shared_urls.produce_squid_regex_list(/* for_pac_server= */ false); +const chrome_regex_text = chrome_regex_list.join('\n') + '\n'; +console.log(chrome_regex_text); + +process.exit(0); \ No newline at end of file diff --git a/shared/urls.js b/shared/urls.js index 7c067ef..a510023 100644 --- a/shared/urls.js +++ b/shared/urls.js @@ -592,23 +592,3 @@ exports.pac_urls = unblock_youku.pac_proxy_urls; exports.pac_bypass_urls = unblock_youku.pac_proxy_bypass_urls; exports.produce_squid_regex_list = produce_squid_regex_list; - - -(function () { - 'use strict'; - - // http://stackoverflow.com/a/5197219 - // http://stackoverflow.com/a/6398335 - if (typeof module !== 'undefined' && module.exports && require.main === module) { - var squid_regex_list; - if (typeof process !== 'undefined' && process.argv[2] === 'PAC') { - squid_regex_list = produce_squid_regex_list(true /* for PAC service */); - } else { - squid_regex_list = produce_squid_regex_list(false /* for Chrome proxy */); - } - - for (var i = 0; i < squid_regex_list.length; i++) { - console.log(squid_regex_list[i]); - } - } -}());