Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #1174 #1189

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions www/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,24 @@
}
});
}
// A few browsers donot support the use of String.prototype.replaceAll method. Hence we define it once we verify that it isn't supported.

Check warning on line 276 in www/js/init.js

View check run for this annotation

codefactor.io / CodeFactor

www/js/init.js#L276

Trailing spaces not allowed. (no-trailing-spaces)
// For documentation visit https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll
if (!String.prototype.replaceAll) {
String.prototype.replaceAll = function (pattern, replacement) {
// verify parameter: It must either be a string or a RegExp with a global flag.
if (typeof pattern[Symbol.replace] === 'function') {
// the pattern is a RegExp check for the presence of g flag.

Check warning on line 282 in www/js/init.js

View check run for this annotation

codefactor.io / CodeFactor

www/js/init.js#L282

Trailing spaces not allowed. (no-trailing-spaces)
if (pattern.global) {
return this.replace(pattern, replacement);
}

Check warning on line 285 in www/js/init.js

View check run for this annotation

codefactor.io / CodeFactor

www/js/init.js#L285

Closing curly brace does not appear on the same line as the subsequent block. (brace-style)
else {
throw new TypeError('Global flag for regular expressions')
}
}
// the pattern is not a RegExp, hence it must be a string.
if (typeof pattern !== 'string') {
throw new TypeError('pattern must either be a string or a RegExp with a global (g) flag.')
}

Check warning on line 293 in www/js/init.js

View check run for this annotation

codefactor.io / CodeFactor

www/js/init.js#L293

Trailing spaces not allowed. (no-trailing-spaces)
return this.replace(new RegExp(pattern, 'g'), replacement);
}
}
Loading