github GeiserX/Wayback-Archive v1.4.4

2 hours ago

Stylesheets and scripts served from a URL without a file extension were archived as HTML.

What was wrong

A stylesheet at /css/main was saved as css/main.html. That was the visible half. The real damage was that an extensionless URL also looks like a page, so the file was run through the HTML processor:

before:  css/main.css  = '<body>@import url("http://example.com/css/theme"); body{color:red}'
         css/theme     never fetched
after:   css/main.css  = '@import url(theme.css);\nbody{color:red}'
         css/theme.css = '.theme{color:blue}'

So the archived stylesheet was wrapped in <body>, its @import still pointed at the live site, and the imported stylesheet was never downloaded.

What changed

The element that referenced a resource already knows what it is — <link rel="stylesheet"> is CSS, <script src> is JS, @import names a stylesheet. That now decides three things instead of being thrown away: the extension the file is saved under, the content type used when neither the URL nor the bytes reveal one, and which resources are treated as pages.

before:  css/main.html   js/bundle.html   image/12345.html
after:   css/main.css    js/bundle.js     image/12345.html

Images and media keep .html. A browser sniffs them whatever the file is called, so the name costs nothing there, and renaming files that already work would gain nothing. rel="icon" and rel="preload" are likewise untouched.

The kind is recorded where a resource is discovered rather than where its link is rewritten, so MAKE_INTERNAL_LINKS_RELATIVE=false no longer changes what a file is — only how it is referenced. The same applies to the Google Fonts and Squarespace paths, which previously built their filename before the naming rule ran.

Verification

476 tests. Alongside the per-case tests there is now an integration test archiving one site that exercises every path that has been wrong across 1.4.3 and 1.4.4 — a stylesheet reached through an extensionless URL, importing another extensionless stylesheet, referenced from a page two directories deep, with img name.png, a#hash.png, café.png, an inline style and a <style> block — asserting nothing in any written file still points at the live site. The 232-combination link/file sweep from 1.4.3 still passes, so nothing reopened.

Don't miss a new Wayback-Archive release

NewReleases is sending notifications on new releases.