Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Fix assignment of options to engine vs script
Browse files Browse the repository at this point in the history
Consider entire option name, not just initial chars. Fixes #1384.
  • Loading branch information
mepard committed Dec 30, 2015
1 parent 4954674 commit c51d700
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/casperjs.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;

interface engine {
string env_varname();
Expand Down Expand Up @@ -120,7 +121,7 @@ class casperjs {
string CASPER_PATH = Path.GetFullPath(Path.Combine(Path.Combine(EXE_FILE, ".."), ".."));

foreach(string arg in args) {
if(arg.StartsWith("--engine")) {
if(arg.StartsWith("--engine=")) {
ENGINE = arg.Substring(9);
break;
}
Expand All @@ -136,12 +137,18 @@ class casperjs {
Environment.Exit(1);
}

Regex arg_regex = new Regex("^--([^=]+)(?:=(.*))?$");

foreach(string arg in args) {
bool found = false;
foreach(string native in ENGINE_NATIVE_ARGS) {
if(arg.StartsWith("--" + native)) {
ENGINE_ARGS.Add(arg);
found = true;
Match arg_match = arg_regex.Match(arg);
if (arg_match.Success) {
string arg_name = arg_match.Groups[0].Captures[0].ToString();
foreach(string native in ENGINE_NATIVE_ARGS) {
if (arg_name == native) {
ENGINE_ARGS.Add(arg);
found = true;
}
}
}

Expand Down

0 comments on commit c51d700

Please sign in to comment.