A source map's "sources" array is a list of URLs, but PostCSS treats them as though they're file paths. This can cause a number of problems, such as incorrectly handling URL-escaped characters, but the biggest issue that comes up in practice is the handling of absolute file:// URLs. They should be converted into absolute file paths, but currently they are not, leading to semantic incompatibilities and weird edge-case behavior.
In the following example, we get a PostCSS filePosition object whose file field is in URL format, despite being documented as a path:
// test.js
const postcss = require('postcss');
const fs = require('fs');
const root = postcss.parse(
fs.readFileSync('test.css', 'utf8'), {from: 'test.css'});
console.log(root.source.input.origin(1, 1));
$ echo 'a {b: c}' > test.scss
$ sass --source-map-urls=absolute test.scss test.css # Dart Sass only
$ node test.js
{ file: 'file:///home/nweiz/goog/postcss/test.scss',
line: 1,
column: 0 }
A source map's
"sources"array is a list of URLs, but PostCSS treats them as though they're file paths. This can cause a number of problems, such as incorrectly handling URL-escaped characters, but the biggest issue that comes up in practice is the handling of absolutefile://URLs. They should be converted into absolute file paths, but currently they are not, leading to semantic incompatibilities and weird edge-case behavior.In the following example, we get a PostCSS
filePositionobject whosefilefield is in URL format, despite being documented as a path: