git.wincent.com
/
hextrapolate.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
328ec43
)
Allow 0x prefix on hex numbers
author
Greg Hurrell <greg@hurrell.net>
Thu, 1 Jun 2017 14:03:16 +0000
(07:03 -0700)
committer
Greg Hurrell <greg@hurrell.net>
Thu, 1 Jun 2017 14:03:16 +0000
(07:03 -0700)
Means that users can type it as a prefix, or paste in a number with this
prefix.
src/Field.react.js
patch
|
blob
|
history
diff --git
a/src/Field.react.js
b/src/Field.react.js
index 6c2362c8cb0658d9d425f55226091e166b1b29c1..b7b3ebda775f8d20bf2437f2664d98682d518de0 100644
(file)
--- a/
src/Field.react.js
+++ b/
src/Field.react.js
@@
-34,8
+34,9
@@
function fromValue(value: ?Value, base: number): string {
}
function getValidator(base) {
+ const prefix = base === 16 ? '(?:0x)?' : '';
return new RegExp(
- `^\\s*[${DIGITS.slice(0, base)}]*\\s*$`,
+ `^\\s*
${prefix}
[${DIGITS.slice(0, base)}]*\\s*$`,
'i'
);
}