Skip to content

Commit

Permalink
fix for valid /[/]/g regex
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Jan 15, 2017
1 parent 9e449f6 commit e0f3930
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -22,6 +22,7 @@
onPush and onPop callbacks
interpeter and terminal accept extra option that can be use in onPop or onPush
all callbacks have terminal as this (terminal in parameter stay the same)
fix for valid /[/]/g regex
0.11.23 add scrollBottomOffset option
0.11.22 scroll to bottom of the terminal when option scrollOnEcho is set to false but the terminal is
at the bottom, add new api methods is_bottom and scroll_to_bottom.
Expand Down
11 changes: 6 additions & 5 deletions js/jquery.terminal-0.11.23.js
Expand Up @@ -31,7 +31,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Sun, 15 Jan 2017 15:49:16 +0000
* Date: Sun, 15 Jan 2017 16:43:06 +0000
*/

/* TODO:
Expand Down Expand Up @@ -2326,14 +2326,15 @@
// ---------------------------------------------------------------------
parse_arguments: function(string) {
var float_re = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;
var re_re = /^\/((?:\\\/|[^\/]|\[[^\]]*\/[^\]]*\])+)\/([gimy]*)$/;
return $.map(string.match(command_re) || [], function(arg) {
if (arg[0] === "'" && arg[arg.length-1] === "'") {
var regex = arg.match(re_re);
if (regex) {
return new RegExp(regex[1], regex[2]);
} else if (arg[0] === "'" && arg[arg.length-1] === "'") {
return arg.replace(/^'|'$/g, '');
} else if (arg[0] === '"' && arg[arg.length-1] === '"') {
return $.parseJSON(arg);
} else if (arg.match(/^\/(\\\/|[^\/])+\/[gimy]*$/)) { // RegEx
var m = arg.match(/^\/([^\/]+)\/([^\/]*)$/);
return new RegExp(m[1], m[2]);
} else if (arg.match(/^-?[0-9]+$/)) {
return parseInt(arg, 10);
} else if (arg.match(float_re)) {
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-0.11.23.min.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions js/jquery.terminal-src.js
Expand Up @@ -2326,14 +2326,15 @@
// ---------------------------------------------------------------------
parse_arguments: function(string) {
var float_re = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;
var re_re = /^\/((?:\\\/|[^\/]|\[[^\]]*\/[^\]]*\])+)\/([gimy]*)$/;
return $.map(string.match(command_re) || [], function(arg) {
if (arg[0] === "'" && arg[arg.length-1] === "'") {
var regex = arg.match(re_re);
if (regex) {
return new RegExp(regex[1], regex[2]);
} else if (arg[0] === "'" && arg[arg.length-1] === "'") {
return arg.replace(/^'|'$/g, '');
} else if (arg[0] === '"' && arg[arg.length-1] === '"') {
return $.parseJSON(arg);
} else if (arg.match(/^\/(\\\/|[^\/])+\/[gimy]*$/)) { // RegEx
var m = arg.match(/^\/([^\/]+)\/([^\/]*)$/);
return new RegExp(m[1], m[2]);
} else if (arg.match(/^-?[0-9]+$/)) {
return parseInt(arg, 10);
} else if (arg.match(float_re)) {
Expand Down
11 changes: 6 additions & 5 deletions js/jquery.terminal.js
Expand Up @@ -31,7 +31,7 @@
* Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
* licensed under 3 clause BSD license
*
* Date: Sun, 15 Jan 2017 15:49:16 +0000
* Date: Sun, 15 Jan 2017 16:43:06 +0000
*/

/* TODO:
Expand Down Expand Up @@ -2326,14 +2326,15 @@
// ---------------------------------------------------------------------
parse_arguments: function(string) {
var float_re = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;
var re_re = /^\/((?:\\\/|[^\/]|\[[^\]]*\/[^\]]*\])+)\/([gimy]*)$/;
return $.map(string.match(command_re) || [], function(arg) {
if (arg[0] === "'" && arg[arg.length-1] === "'") {
var regex = arg.match(re_re);
if (regex) {
return new RegExp(regex[1], regex[2]);
} else if (arg[0] === "'" && arg[arg.length-1] === "'") {
return arg.replace(/^'|'$/g, '');
} else if (arg[0] === '"' && arg[arg.length-1] === '"') {
return $.parseJSON(arg);
} else if (arg.match(/^\/(\\\/|[^\/])+\/[gimy]*$/)) { // RegEx
var m = arg.match(/^\/([^\/]+)\/([^\/]*)$/);
return new RegExp(m[1], m[2]);
} else if (arg.match(/^-?[0-9]+$/)) {
return parseInt(arg, 10);
} else if (arg.match(float_re)) {
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

0 comments on commit e0f3930

Please sign in to comment.