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

[3_1_X][TIMOB-26455] Sanitize numeric names #308

Merged
merged 1 commit into from
Oct 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions android/hooks/metabase/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ function safeName(name) {
if (name.match(/^(decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|escape|eval|isFinite|isNaN|parseFloat|parseInt|unescape|uneval)$/)) {
return '_' + name;
}
// Replace numeric prefix
if (name.match(/^\d+/)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (name.match(/^\d+/)) {
if (/^\d+/.test(name)) {

To just test the string for a match test is considerably faster. Shouldn't be much of an issue here but just for future reference (and i wanted to test the new suggest feature^^)

return '_' + name;
}
return name;
}

Expand Down