Skip to content

Dugs template causes Chrome to crash if wrong endpoint #13

Description

@marcobarbosa

Found an interesting issue with the template engine of Dug.js.

If you specify a wrong url like:
endpoint: 'https://api.pinterest.com/foobar

The script will just give a 404 correctly and do nothing.

Now if you go deeper and just add a little typo in the url:
endpoint: 'https://api.pinterest.com/v3/pidgets/boards/rogieking/my-illustration-style-typo/pins/'

Chrome will crash because the template engine will keep looking for data.data.pins.

A workaround for this is to set data.data.pins to something:

beforeRender: function( data ){ if (data.status === "failure") { // Hack: give something to the template to be happy data.data = { pins: [] }; (...)

So the template will get an empty object and do nothing.

As far as I understood the "error" callback will only be called if there's an error such a network error. If you have a typo in the endpoint url, the call will be a success but with empty data (without pins). So the error callback won't be called and the template will hang.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions