Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MangaElt.js #122

Merged
merged 1 commit into from
Dec 2, 2015
Merged

Update MangaElt.js #122

merged 1 commit into from
Dec 2, 2015

Conversation

athalius
Copy link
Contributor

@athalius athalius commented Sep 2, 2014

This should fix merges #111
Trying to parse an array, that is already been parsed and instatntiated as an array is gonna blow up.

Test case:

{\"mirror\":\"Manga-Fox\",\"name\":\"1/2 Prince\",\"url\":\"http://mangafox.me/manga/1_2_prince/\",\"lastChapterReadURL\":\"http://mangafox.me/manga/1_2_prince/v14/c069/\",\"lastChapterReadName\":\"1/2 Prince 69\",\"read\":0,\"update\":1,\"ts\":1407828322,\"display\":0,\"cats\":\"[]\"},

This should fix merges AllMangasReader-dev#111
Trying to parse an array, that is already been parsed and instatntiated as an array is gonna blow up.

Test case:{\"mirror\":\"Manga-Fox\",\"name\":\"1/2 Prince\",\"url\":\"http://mangafox.me/manga/1_2_prince/\",\"lastChapterReadURL\":\"http://mangafox.me/manga/1_2_prince/v14/c069/\",\"lastChapterReadName\":\"1/2 Prince 69\",\"read\":0,\"update\":1,\"ts\":1407828322,\"display\":0,\"cats\":\"[]\"},
@braiam
Copy link
Member

braiam commented Sep 15, 2014

That test case is invalid. The importData function is doing what's supposed to do. Can you change it for another where it demonstrate the problem?

@athalius
Copy link
Contributor Author

Whoops got a bit lazy in snipping.

{"mangas":"[{\"mirror\":\"Manga-Fox\",\"name\":\"1/2 Prince\",\"url\":\"http://mangafox.me/manga/1_2_prince/\",\"lastChapterReadURL\":\"http://mangafox.me/manga/1_2_prince/v14/c069/\",\"lastChapterReadName\":\"1/2 Prince 69\",\"read\":0,\"update\":1,\"ts\":1407828322,\"display\":0,\"cats\":\"[]\"}]","bookmarks":"[]"}

is a valid string that will be read ( or will blow up at least :))

@braiam
Copy link
Member

braiam commented Sep 15, 2014

Um... it worked fine? What is the issue I'm supposed to see?

@stardisblue
Copy link

well, sometimes it triggers an error (unexpected en of input) because of JSON.parse(obj.cats) when cats is empty 'cause obj.cats is already a Json object ...

i fixed it locally by changing the MangaElt.js lines 122-124

    if (obj.cats !== undefined && obj.cats !== null) {
        this.cats = (typeof obj.cats ==='object')? obj.cats : JSON.parse(obj.cats) || [];
    }

braiam added a commit that referenced this pull request Dec 2, 2015
@braiam braiam merged commit 9c767e6 into AllMangasReader-dev:develop Dec 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants