Commit 942857c3 authored by Florent Chehab's avatar Florent Chehab

Merge branch 'fix_firefox_bug' into 'master'

Fixes #73 removed firefox bug with regex

Closes #73

See merge request !59
parents 3f046ea5 33da560a
Pipeline #36061 passed with stages
in 12 minutes and 2 seconds
......@@ -4,11 +4,12 @@
* @returns
*/
function getMoneyRegex() {
return /(?<!`):(\d*[.,]?\d*)(\w{3}):/g;
// regex lookbehind is not supported in Firefox at this time
// can't use it to detect code markdown: /(?<!`):(\d*[.,]?\d*)(\w{3}):/g;
return /:(\d*[.,]?\d*)(\w{3}):/g;
}
/**
* Parses a string to determine if there are some currency in it.
*
......@@ -46,7 +47,12 @@ export default function parseMoney(str) {
amount = parseFloat(match["1"].replace(",", ".")), // fix numbers with "," as decimal separators
currency = match["2"].toUpperCase(); // make sure the currency is uppercase
matches.push({ matchStartIndex, matchLastIndex, amount, currency });
// regex lookbehind is not supported in Firefox at this time
if (matchStartIndex !== 0 && str[matchStartIndex - 1] === "`") {
// ignore it's for code
} else {
matches.push({ matchStartIndex, matchLastIndex, amount, currency });
}
}
let res = [], lastIndex = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment