Skip to content

Commit

Permalink
#1046 - accept url with just www prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
kensoh committed Jun 2, 2021
1 parent e12d449 commit 6f259b2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/tagui
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/tagui.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/tagui_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 + "\"})";}

Expand Down
5 changes: 3 additions & 2 deletions src/tagui_parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 6f259b2

Please sign in to comment.