lakenen / node-box-view

A node client for the Box View API
MIT License
13 stars 2 forks source link

Error with non-standard char in options.params.name in uploadURL #15

Closed emmettnicholas closed 9 years ago

emmettnicholas commented 9 years ago

An error is thrown after I call uploadURL with [options.params.name] set as foo’bar.pdf (note the non-standard apostrophe char: , not ').

Error: JSON parse error - Unterminated string starting at: line 1 column 57 (char 57)
    at handleError (/asdf/node_modules/box-view/index.js:127:18)
    at handleResponse (/asdf/node_modules/box-view/index.js:197:13)

It works when I use the regular apostrophe character. When I call the box-view API directly (e.g. curl from command line), it accepts the special character.

I am on v1.1.0. Thanks!

lakenen commented 9 years ago

@emmettnicholas I can't seem to reproduce this issue. Do you have some sample code I could look at?

emmettnicholas commented 9 years ago

Sure-- this triggers the error:

var boxView = require('box-view');

var boxViewClient = boxView.createClient('BOX_VIEW_API_KEY');

var url = 'https://s3.amazonaws.com/forma_app_filepicker_dev-test-staging/lGLy0XRZSF25TmAOM9o6_lorem%E2%80%99ipsum.pdf';
var name = 'lorem’ipsum.pdf';

boxViewClient.documents.uploadURL(url, {
    params: {
        name: name
    },
    retry: true
}, function(err, responseData, httpResponse) {
    if (err) {
        console.log(err);
    } else {
        var boxDocumentId = responseData.id;
        var boxDocumentStatus = responseData.status;
        console.log(boxDocumentId, boxDocumentStatus);
    }
});
lakenen commented 9 years ago

Cool, that repros for me. Looking into it now...

lakenen commented 9 years ago

Fixed published in v1.1.1