Skip to main content

Module rewrite

Module rewrite 

Source
Expand description

Known-host URL rewrites that turn an agent-friendly page URL into the URL that actually yields clean content.

GitHub blob pages are JS-rendered: fetching them as HTML returns navigation chrome (“Star”, “Fork”, “Uh oh! There was an error while loading”) instead of the file, and the raw HTML is enormous. The file’s real bytes live on raw.githubusercontent.com. Rewriting …/blob/<ref>/<path> (and the equivalent …/raw/<ref>/<path>) to that host gives the agent the actual file in one bounded fetch (GH feedback: reading GitHub pages directly hangs/garbles).

Functions§

rewrite_url
Rewrite a known page URL to its clean-content equivalent, or None if no rule applies (the original URL is then used unchanged).