{"action":"opened","issue":{"url":"https://api.github.com/repos/punkave/sanitize-html/issues/81","labels_url":"https://api.github.com/repos/punkave/sanitize-html/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/punkave/sanitize-html/issues/81/comments","events_url":"https://api.github.com/repos/punkave/sanitize-html/issues/81/events","html_url":"https://github.com/punkave/sanitize-html/issues/81","id":119314803,"number":81,"title":"Always returns a non-empty string","user":{"login":"franciscop","id":2801252,"avatar_url":"https://avatars.githubusercontent.com/u/2801252?v=3","gravatar_id":"","url":"https://api.github.com/users/franciscop","html_url":"https://github.com/franciscop","followers_url":"https://api.github.com/users/franciscop/followers","following_url":"https://api.github.com/users/franciscop/following{/other_user}","gists_url":"https://api.github.com/users/franciscop/gists{/gist_id}","starred_url":"https://api.github.com/users/franciscop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/franciscop/subscriptions","organizations_url":"https://api.github.com/users/franciscop/orgs","repos_url":"https://api.github.com/users/franciscop/repos","events_url":"https://api.github.com/users/franciscop/events{/privacy}","received_events_url":"https://api.github.com/users/franciscop/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-28T19:43:18Z","updated_at":"2015-11-28T19:43:18Z","closed_at":null,"body":"For debugging purposes I arrived to this test-case:\r\n\r\n```js\r\nconsole.log(\"Undefined\", sanitize(), typeof sanitize());\r\nconsole.log(\"Empty\", sanitize(''), typeof sanitize(''));\r\nconsole.log(\"False\", sanitize(false), typeof sanitize(false));\r\n```\r\n\r\nGives an unexpected output:\r\n\r\n```js\r\nUndefined undefined string\r\nEmpty  string\r\nFalse false string\r\n```\r\n\r\nSo basically if nothing is passed, it will return an string that says \"undefined\" which is really odd (and was a weird bug to debug). Therefore it'll pass all successive tests to check the html, since there *will be* a non-empty string. For example, in jade for a \"sanitized\" html:\r\n\r\n```jade\r\n// Always returns true (not expected)\r\nif !html\r\nif (typeof html !== \"undefined\")\r\nif (html.length > 0)\r\n// ... at this point I was wondering, since jade's output displayed \"undefined\"\r\n\r\n// Just for the kicks, this misteriously worked:\r\nif (html === \"undefined\")\r\n```\r\n\r\nSo as you can see, it is a really weird output when a non-valid string is set as input.\r\n\r\n## Proposed solution\r\n\r\nFor the same case as before, you could return some of these \"more sensible\" outputs:\r\n\r\n1. false\r\n2. \"\"\r\n3. undefined\r\n4. throw Error\r\n\r\nI think all of them are better than the current usage, but I highly recommend either 1. or 2. which are both *falsy*."}}