From 6f259b20c590d95459d3565a219fc8e0091348cb Mon Sep 17 00:00:00 2001 From: Ken Soh Date: Wed, 2 Jun 2021 14:30:02 +0800 Subject: [PATCH] #1046 - accept url with just www prefix --- src/tagui | 2 +- src/tagui.cmd | 2 +- src/tagui_header.js | 5 +++-- src/tagui_parse.php | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tagui b/src/tagui index d5231fe4..f0110af3 100755 --- a/src/tagui +++ b/src/tagui @@ -6,7 +6,7 @@ chrome_command="google-chrome" if [ -z "$1" ] then -echo "tagui v6.36: use following options and this syntax to run - ./tagui flow_filename option(s)" +echo "tagui v6.40: use following options and this syntax to run - ./tagui flow_filename option(s)" echo echo "tagui live launch TagUI live mode enabled with visual automation for interactive development" echo "input(s) add your own parameter(s) to be used in your automation flow as variables p1 to p8" diff --git a/src/tagui.cmd b/src/tagui.cmd index 79ee2255..5a7a464b 100644 --- a/src/tagui.cmd +++ b/src/tagui.cmd @@ -14,7 +14,7 @@ rem enable windows for loop advanced flow control setlocal enableextensions enabledelayedexpansion if "%~1"=="" ( -echo tagui v6.36: use following options and this syntax to run - tagui flow_filename option^(s^) +echo tagui v6.40: use following options and this syntax to run - tagui flow_filename option^(s^) echo. echo tagui live launch TagUI live mode enabled with visual automation for interactive development echo input^(s^) add your own parameter^(s^) to be used in your automation flow as variables p1 to p8 diff --git a/src/tagui_header.js b/src/tagui_header.js index 194d799d..a8cace1e 100644 --- a/src/tagui_header.js +++ b/src/tagui_header.js @@ -826,7 +826,7 @@ if (inside_py_block !== 0) return 'py'; if (inside_r_block !== 0) return 'r'; if (inside_run_block !== 0) return 'run'; if (inside_vision_block !== 0) return 'vision'; if (inside_js_block !== 0) return 'js'; if (inside_dom_block !== 0) return 'dom'; -if (lc_raw_intent.substr(0,7) == 'http://' || lc_raw_intent.substr(0,8) == 'https://') return 'url'; +if (lc_raw_intent.substr(0,7) == 'http://' || lc_raw_intent.substr(0,8) == 'https://' || lc_raw_intent.substr(0,4) == 'www.') return 'url'; // first set of conditions check for valid keywords with their parameters if ((lc_raw_intent.substr(0,4) == 'tap ') || (lc_raw_intent.substr(0,6) == 'click ')) return 'tap'; @@ -1004,7 +1004,8 @@ if (!fs.exists('tagui_py/tagui_py.in')) return "this.echo('ERROR - cannot initia if (!fs.exists('tagui_py/tagui_py.out')) return "this.echo('ERROR - cannot initialise tagui_py.out')"; return "py_result = ''; if (!py_step('"+input_intent+"')) this.echo('ERROR - cannot execute Python command(s)'); else {py_result = fetch_py_text(); clear_py_text(); try {py_json = JSON.parse(py_result);} catch(e) {py_json = JSON.parse('null');}}";} -function url_intent(raw_intent) {raw_intent = eval("'" + escape_bs(raw_intent) + "'"); // support dynamic variables +function url_intent(raw_intent) {if (raw_intent.toLowerCase().substr(0,4) == 'www.') raw_intent = 'https://' + raw_intent; +raw_intent = eval("'" + escape_bs(raw_intent) + "'"); // support dynamic variables if (chrome_id == 0) return "this.echo('ERROR - step only supported in live mode using Chrome browser')"; else return "this.evaluate(function() {window.location.href = \"" + raw_intent + "\"})";} diff --git a/src/tagui_parse.php b/src/tagui_parse.php index ea6533ea..a3d85713 100755 --- a/src/tagui_parse.php +++ b/src/tagui_parse.php @@ -498,7 +498,7 @@ function get_intent($raw_intent) {$lc_raw_intent = strtolower($raw_intent); $GLOBALS['inside_dom_block'] != 0) return "integration_block"; if ($GLOBALS['inside_run_block'] != 0) return "run"; -if ((substr($lc_raw_intent,0,7)=="http://") or (substr($lc_raw_intent,0,8)=="https://") or (substr($lc_raw_intent,0,11)=="about:blank")) return "url"; // recognizing about:blank as valid URL as it is part of HTML5 standard +if ((substr($lc_raw_intent,0,7)=="http://") or (substr($lc_raw_intent,0,8)=="https://") or (substr($lc_raw_intent,0,4)=="www.") or (substr($lc_raw_intent,0,11)=="about:blank")) return "url"; // recognizing about:blank as valid URL as it is part of HTML5 standard // first set of conditions check for valid keywords with their parameters if ((substr($lc_raw_intent,0,4)=="tap ") or (substr($lc_raw_intent,0,6)=="click ")) return "tap"; @@ -690,7 +690,8 @@ function call_py($input_intent) { // helper function to use Python integration f end_fi()."});\n\n";} // set of functions to interpret steps into corresponding casperjs code -function url_intent($raw_intent) {$twb = $GLOBALS['tagui_web_browser']; $casper_url = $raw_intent; $chrome_call = ''; +function url_intent($raw_intent) {if (substr(strtolower($raw_intent),0,4)=="www.") $raw_intent = "https://" . $raw_intent; +$twb = $GLOBALS['tagui_web_browser']; $casper_url = $raw_intent; $chrome_call = ''; if ($twb == 'chrome') {$chrome_call = "var download_path = flow_path; // to set path correctly for Windows\n" . "if (download_path.indexOf(':')>0) download_path = download_path.replace(/\//g,'\\\\').replace(/\\\\/g,'\\\\');\n" . "chrome_step('Page.setDownloadBehavior',{behavior: 'allow', downloadPath: download_path});\n";