Fix Uncaught SyntaxError: Unexpected end of input

When window[method].getItem(key) returns '', it will caught 'Uncaught SyntaxError: Unexpected end of input' error.