Skip to content

feat: detect extensionless remote JSON responses - #958

Open
officialasishkumar wants to merge 1 commit into
charmbracelet:masterfrom
officialasishkumar:feat/remote-json-content-type
Open

feat: detect extensionless remote JSON responses#958
officialasishkumar wants to merge 1 commit into
charmbracelet:masterfrom
officialasishkumar:feat/remote-json-content-type

Conversation

@officialasishkumar

Copy link
Copy Markdown

Summary

Adds JSON detection for remote HTTP sources that do not have a .json extension.

Glow already renders local .json files and remote .json URLs as code. This records the HTTP Content-Type for remote sources and treats extensionless application/json and +json responses as JSON code blocks, while keeping markdown extensions extension-first.

Testing

  • go test ./...
  • go test -race -covermode atomic ./...
  • git diff --check

Fixes #910

Remote HTTP sources without file extensions were always treated as markdown, even when the server identified the payload as JSON. That made API endpoints render as prose instead of a highlighted code block.

Record the HTTP Content-Type for remote sources and use JSON media types, including +json variants, as the code block language only when the URL has no extension.

Fixes charmbracelet#910
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.

Handle remote JSON without an extension.

1 participant