JSONP Highlight plugin doesn't handle 301 redirects
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 13k
- Forks
- 1.4k
- Avg merge
- 15h 36m
- Merged PRs (30d)
- 3
Description
Information:
- Prism version: 1.24.1
- Plugins: jsonp-highlight
- Environment: Browser
Description
The example below is the minimal example from the docs:
<pre
class="language-javascript"
data-jsonp="https://api.github.com/repos/leaverou/prism/contents/prism.js">
</pre>
... which for me resulted in the following being rendered:
✖ Error: Cannot parse response (perhaps you need an adapter function?)
Debugging the error with the dev tools reveals that the problem is the 301 response:

As soon as I change data-jsonp to the redirect location https://api.github.com/repositories/4979467/contents/prism.js?callback=prismjsonp0, everything works as expected.
Solution
- Handle 301 status codes
- Temporarily update the minimal example in the docs with an URL that returns a status code 400, so people don't get confused
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the jsonp-highlight plugin entry point and the minimal JSONP example in the documentation. Reproduce the request using the documented GitHub URL and inspect how the 301 response is handled. Done means redirected responses work and the documentation example no longer points to a confusing URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100