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

When the slug is malformed, the error message cannot be parsed because it is not valid JSON #434

Open
jamesmortensen opened this issue Oct 17, 2021 · 0 comments

Comments

@jamesmortensen
Copy link

I wanted to get the full path in my slug, so I added a '/' between "post" and the last part of the URL. The error I see in the console is:

error message = path contains a malformed path component: {"resource":"Commit","field":"path","code":"invalid"}
SyntaxError: Unexpected token p in JSON at position 0
    at JSON.parse (<anonymous>)
    at /Users/james/Dev/hugo/staticman/lib/GitHub.js:114:38
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

I added the log statement on GitHub.js line 112 to see why the JSON.parse(message) was not working properly. I think the code may need to be modified to split the message apart from the JSON object so the JSON object can be properly parsed. Hope this helps.

To replicate, use this for your slug <input type="hidden" name="options[slug]" value="{{ replaceRE "/$" "$1" $.RelPermalink }}">

I recognize what I'm trying to do may not be correct, but this issue is about the error handling part. Hope this helps.

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

No branches or pull requests

1 participant