{"action":"created","comment":{"url":"https://api.github.com/repos/ScottLogic/finput/pulls/comments/125980326","pull_request_review_id":48423382,"id":125980326,"diff_hunk":"@@ -179,8 +179,34 @@ exports.allowedZero = function(val, char, caretPos, options) {\n  * @param {val} string value to convert to a number\n  * @param {options} Finput options object\n  */\n-exports.toNumber = function(val, options) {\n-  return val && Number(val.replace(new RegExp(`[${options.thousands}]`, 'g'), ''));\n+exports.toNumber = function(stringValue, options) {\n+  if (!stringValue) return null;\n+\n+  // Number(...) accepts thousands ',' or '' and decimal '.' so we must:\n+\n+  // 1. Remove thousands delimiter to cover case it is not ','\n+  // Cannot replace with ',' in case decimal uses this\n+  stringValue = stringValue.replace(new RegExp(`[${options.thousands}]`, 'g'), '')\n+  \n+  // 2. Replace decimal with '.' to cover case it is not '.'\n+  // Ok to replace as thousands delimiter removed above\n+  stringValue = stringValue.replace(new RegExp(`[${options.decimal}]`, 'g'), '.')\n+  return Number(stringValue);","path":"src/helpers.js","position":18,"original_position":18,"commit_id":"6d521bd555daad41260dc245e9832305c291d153","original_commit_id":"6d521bd555daad41260dc245e9832305c291d153","user":{"login":"oriondean","id":3110057,"avatar_url":"https://avatars3.githubusercontent.com/u/3110057?v=3","gravatar_id":"","url":"https://api.github.com/users/oriondean","html_url":"https://github.com/oriondean","followers_url":"https://api.github.com/users/oriondean/followers","following_url":"https://api.github.com/users/oriondean/following{/other_user}","gists_url":"https://api.github.com/users/oriondean/gists{/gist_id}","starred_url":"https://api.github.com/users/oriondean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oriondean/subscriptions","organizations_url":"https://api.github.com/users/oriondean/orgs","repos_url":"https://api.github.com/users/oriondean/repos","events_url":"https://api.github.com/users/oriondean/events{/privacy}","received_events_url":"https://api.github.com/users/oriondean/received_events","type":"User","site_admin":false},"body":"Also, these lines are semi colons","created_at":"2017-07-06T18:32:47Z","updated_at":"2017-07-06T18:39:20Z","html_url":"https://github.com/ScottLogic/finput/pull/76#discussion_r125980326","pull_request_url":"https://api.github.com/repos/ScottLogic/finput/pulls/76","_links":{"self":{"href":"https://api.github.com/repos/ScottLogic/finput/pulls/comments/125980326"},"html":{"href":"https://github.com/ScottLogic/finput/pull/76#discussion_r125980326"},"pull_request":{"href":"https://api.github.com/repos/ScottLogic/finput/pulls/76"}}},"pull_request":{"url":"https://api.github.com/repos/ScottLogic/finput/pulls/76","id":128606846,"html_url":"https://github.com/ScottLogic/finput/pull/76","diff_url":"https://github.com/ScottLogic/finput/pull/76.diff","patch_url":"https://github.com/ScottLogic/finput/pull/76.patch","issue_url":"https://api.github.com/repos/ScottLogic/finput/issues/76","number":76,"state":"open","locked":false,"title":"Add setOptions","user":{"login":"ryanggrey","id":1911474,"avatar_url":"https://avatars0.githubusercontent.com/u/1911474?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanggrey","html_url":"https://github.com/ryanggrey","followers_url":"https://api.github.com/users/ryanggrey/followers","following_url":"https://api.github.com/users/ryanggrey/following{/other_user}","gists_url":"https://api.github.com/users/ryanggrey/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanggrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanggrey/subscriptions","organizations_url":"https://api.github.com/users/ryanggrey/orgs","repos_url":"https://api.github.com/users/ryanggrey/repos","events_url":"https://api.github.com/users/ryanggrey/events{/privacy}","received_events_url":"https://api.github.com/users/ryanggrey/received_events","type":"User","site_admin":false},"body":"Using `setRawValue` to redraw the finput element when switching options revealed a couple of issues with thousands/decimal delimiters which is also fixed in this PR.","created_at":"2017-07-03T11:19:03Z","updated_at":"2017-07-06T18:39:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dd28102ab711687258b0e408a1a2db87a47eed7d","assignee":null,"assignees":[],"requested_reviewers":[{"login":"chrisprice","id":433457,"avatar_url":"https://avatars0.githubusercontent.com/u/433457?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisprice","html_url":"https://github.com/chrisprice","followers_url":"https://api.github.com/users/chrisprice/followers","following_url":"https://api.github.com/users/chrisprice/following{/other_user}","gists_url":"https://api.github.com/users/chrisprice/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisprice/subscriptions","organizations_url":"https://api.github.com/users/chrisprice/orgs","repos_url":"https://api.github.com/users/chrisprice/repos","events_url":"https://api.github.com/users/chrisprice/events{/privacy}","received_events_url":"https://api.github.com/users/chrisprice/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ScottLogic/finput/pulls/76/commits","review_comments_url":"https://api.github.com/repos/ScottLogic/finput/pulls/76/comments","review_comment_url":"https://api.github.com/repos/ScottLogic/finput/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ScottLogic/finput/issues/76/comments","statuses_url":"https://api.github.com/repos/ScottLogic/finput/statuses/6d521bd555daad41260dc245e9832305c291d153","head":{"label":"ryanggrey:set-options","ref":"set-options","sha":"6d521bd555daad41260dc245e9832305c291d153","user":{"login":"ryanggrey","id":1911474,"avatar_url":"https://avatars0.githubusercontent.com/u/1911474?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanggrey","html_url":"https://github.com/ryanggrey","followers_url":"https://api.github.com/users/ryanggrey/followers","following_url":"https://api.github.com/users/ryanggrey/following{/other_user}","gists_url":"https://api.github.com/users/ryanggrey/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanggrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanggrey/subscriptions","organizations_url":"https://api.github.com/users/ryanggrey/orgs","repos_url":"https://api.github.com/users/ryanggrey/repos","events_url":"https://api.github.com/users/ryanggrey/events{/privacy}","received_events_url":"https://api.github.com/users/ryanggrey/received_events","type":"User","site_admin":false},"repo":{"id":95096164,"name":"finput","full_name":"ryanggrey/finput","owner":{"login":"ryanggrey","id":1911474,"avatar_url":"https://avatars0.githubusercontent.com/u/1911474?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanggrey","html_url":"https://github.com/ryanggrey","followers_url":"https://api.github.com/users/ryanggrey/followers","following_url":"https://api.github.com/users/ryanggrey/following{/other_user}","gists_url":"https://api.github.com/users/ryanggrey/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanggrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanggrey/subscriptions","organizations_url":"https://api.github.com/users/ryanggrey/orgs","repos_url":"https://api.github.com/users/ryanggrey/repos","events_url":"https://api.github.com/users/ryanggrey/events{/privacy}","received_events_url":"https://api.github.com/users/ryanggrey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ryanggrey/finput","description":"Financial number input","fork":true,"url":"https://api.github.com/repos/ryanggrey/finput","forks_url":"https://api.github.com/repos/ryanggrey/finput/forks","keys_url":"https://api.github.com/repos/ryanggrey/finput/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ryanggrey/finput/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ryanggrey/finput/teams","hooks_url":"https://api.github.com/repos/ryanggrey/finput/hooks","issue_events_url":"https://api.github.com/repos/ryanggrey/finput/issues/events{/number}","events_url":"https://api.github.com/repos/ryanggrey/finput/events","assignees_url":"https://api.github.com/repos/ryanggrey/finput/assignees{/user}","branches_url":"https://api.github.com/repos/ryanggrey/finput/branches{/branch}","tags_url":"https://api.github.com/repos/ryanggrey/finput/tags","blobs_url":"https://api.github.com/repos/ryanggrey/finput/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ryanggrey/finput/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ryanggrey/finput/git/refs{/sha}","trees_url":"https://api.github.com/repos/ryanggrey/finput/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ryanggrey/finput/statuses/{sha}","languages_url":"https://api.github.com/repos/ryanggrey/finput/languages","stargazers_url":"https://api.github.com/repos/ryanggrey/finput/stargazers","contributors_url":"https://api.github.com/repos/ryanggrey/finput/contributors","subscribers_url":"https://api.github.com/repos/ryanggrey/finput/subscribers","subscription_url":"https://api.github.com/repos/ryanggrey/finput/subscription","commits_url":"https://api.github.com/repos/ryanggrey/finput/commits{/sha}","git_commits_url":"https://api.github.com/repos/ryanggrey/finput/git/commits{/sha}","comments_url":"https://api.github.com/repos/ryanggrey/finput/comments{/number}","issue_comment_url":"https://api.github.com/repos/ryanggrey/finput/issues/comments{/number}","contents_url":"https://api.github.com/repos/ryanggrey/finput/contents/{+path}","compare_url":"https://api.github.com/repos/ryanggrey/finput/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ryanggrey/finput/merges","archive_url":"https://api.github.com/repos/ryanggrey/finput/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ryanggrey/finput/downloads","issues_url":"https://api.github.com/repos/ryanggrey/finput/issues{/number}","pulls_url":"https://api.github.com/repos/ryanggrey/finput/pulls{/number}","milestones_url":"https://api.github.com/repos/ryanggrey/finput/milestones{/number}","notifications_url":"https://api.github.com/repos/ryanggrey/finput/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ryanggrey/finput/labels{/name}","releases_url":"https://api.github.com/repos/ryanggrey/finput/releases{/id}","deployments_url":"https://api.github.com/repos/ryanggrey/finput/deployments","created_at":"2017-06-22T09:04:47Z","updated_at":"2017-06-22T09:04:48Z","pushed_at":"2017-07-06T14:44:51Z","git_url":"git://github.com/ryanggrey/finput.git","ssh_url":"git@github.com:ryanggrey/finput.git","clone_url":"https://github.com/ryanggrey/finput.git","svn_url":"https://github.com/ryanggrey/finput","homepage":"http://scottlogic.github.io/finput","size":706,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ScottLogic:master","ref":"master","sha":"8f81a90906608e01394b0891368638500003ec12","user":{"login":"ScottLogic","id":2046037,"avatar_url":"https://avatars0.githubusercontent.com/u/2046037?v=3","gravatar_id":"","url":"https://api.github.com/users/ScottLogic","html_url":"https://github.com/ScottLogic","followers_url":"https://api.github.com/users/ScottLogic/followers","following_url":"https://api.github.com/users/ScottLogic/following{/other_user}","gists_url":"https://api.github.com/users/ScottLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/ScottLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScottLogic/subscriptions","organizations_url":"https://api.github.com/users/ScottLogic/orgs","repos_url":"https://api.github.com/users/ScottLogic/repos","events_url":"https://api.github.com/users/ScottLogic/events{/privacy}","received_events_url":"https://api.github.com/users/ScottLogic/received_events","type":"Organization","site_admin":false},"repo":{"id":49269412,"name":"finput","full_name":"ScottLogic/finput","owner":{"login":"ScottLogic","id":2046037,"avatar_url":"https://avatars0.githubusercontent.com/u/2046037?v=3","gravatar_id":"","url":"https://api.github.com/users/ScottLogic","html_url":"https://github.com/ScottLogic","followers_url":"https://api.github.com/users/ScottLogic/followers","following_url":"https://api.github.com/users/ScottLogic/following{/other_user}","gists_url":"https://api.github.com/users/ScottLogic/gists{/gist_id}","starred_url":"https://api.github.com/users/ScottLogic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScottLogic/subscriptions","organizations_url":"https://api.github.com/users/ScottLogic/orgs","repos_url":"https://api.github.com/users/ScottLogic/repos","events_url":"https://api.github.com/users/ScottLogic/events{/privacy}","received_events_url":"https://api.github.com/users/ScottLogic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ScottLogic/finput","description":"Financial number input","fork":false,"url":"https://api.github.com/repos/ScottLogic/finput","forks_url":"https://api.github.com/repos/ScottLogic/finput/forks","keys_url":"https://api.github.com/repos/ScottLogic/finput/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ScottLogic/finput/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ScottLogic/finput/teams","hooks_url":"https://api.github.com/repos/ScottLogic/finput/hooks","issue_events_url":"https://api.github.com/repos/ScottLogic/finput/issues/events{/number}","events_url":"https://api.github.com/repos/ScottLogic/finput/events","assignees_url":"https://api.github.com/repos/ScottLogic/finput/assignees{/user}","branches_url":"https://api.github.com/repos/ScottLogic/finput/branches{/branch}","tags_url":"https://api.github.com/repos/ScottLogic/finput/tags","blobs_url":"https://api.github.com/repos/ScottLogic/finput/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ScottLogic/finput/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ScottLogic/finput/git/refs{/sha}","trees_url":"https://api.github.com/repos/ScottLogic/finput/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ScottLogic/finput/statuses/{sha}","languages_url":"https://api.github.com/repos/ScottLogic/finput/languages","stargazers_url":"https://api.github.com/repos/ScottLogic/finput/stargazers","contributors_url":"https://api.github.com/repos/ScottLogic/finput/contributors","subscribers_url":"https://api.github.com/repos/ScottLogic/finput/subscribers","subscription_url":"https://api.github.com/repos/ScottLogic/finput/subscription","commits_url":"https://api.github.com/repos/ScottLogic/finput/commits{/sha}","git_commits_url":"https://api.github.com/repos/ScottLogic/finput/git/commits{/sha}","comments_url":"https://api.github.com/repos/ScottLogic/finput/comments{/number}","issue_comment_url":"https://api.github.com/repos/ScottLogic/finput/issues/comments{/number}","contents_url":"https://api.github.com/repos/ScottLogic/finput/contents/{+path}","compare_url":"https://api.github.com/repos/ScottLogic/finput/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ScottLogic/finput/merges","archive_url":"https://api.github.com/repos/ScottLogic/finput/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ScottLogic/finput/downloads","issues_url":"https://api.github.com/repos/ScottLogic/finput/issues{/number}","pulls_url":"https://api.github.com/repos/ScottLogic/finput/pulls{/number}","milestones_url":"https://api.github.com/repos/ScottLogic/finput/milestones{/number}","notifications_url":"https://api.github.com/repos/ScottLogic/finput/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ScottLogic/finput/labels{/name}","releases_url":"https://api.github.com/repos/ScottLogic/finput/releases{/id}","deployments_url":"https://api.github.com/repos/ScottLogic/finput/deployments","created_at":"2016-01-08T11:53:15Z","updated_at":"2017-06-21T15:35:57Z","pushed_at":"2017-07-06T14:44:52Z","git_url":"git://github.com/ScottLogic/finput.git","ssh_url":"git@github.com:ScottLogic/finput.git","clone_url":"https://github.com/ScottLogic/finput.git","svn_url":"https://github.com/ScottLogic/finput","homepage":"http://scottlogic.github.io/finput","size":679,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5,"mirror_url":null,"open_issues_count":21,"forks":5,"open_issues":21,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ScottLogic/finput/pulls/76"},"html":{"href":"https://github.com/ScottLogic/finput/pull/76"},"issue":{"href":"https://api.github.com/repos/ScottLogic/finput/issues/76"},"comments":{"href":"https://api.github.com/repos/ScottLogic/finput/issues/76/comments"},"review_comments":{"href":"https://api.github.com/repos/ScottLogic/finput/pulls/76/comments"},"review_comment":{"href":"https://api.github.com/repos/ScottLogic/finput/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ScottLogic/finput/pulls/76/commits"},"statuses":{"href":"https://api.github.com/repos/ScottLogic/finput/statuses/6d521bd555daad41260dc245e9832305c291d153"}}}}
{"actor":{"display_login":"oriondean"}}