reworkcss/css — pull request #28 by lydell (2014-06-04 19:10:00+00:00)
Title: Make relative applied source paths relative to CWD

When generating a source map, the paths put into the `sources` array of
the source map normally come from `pos.source` properties on the AST
nodes. These are today assumed to be relative to the current working
directory, since that’s how any original source maps are resolved and
applied.

Paths in the `sources` array can also come from applied original maps.
Relative such source paths are relative to the original source map --
not to the current working directory!

It does not make sense to mix paths that are relative to different
things. Therefore this commit makes sure that applied relative source
maps are rewritten to be relative to the current working directory, like
all other sources.

An existing test was updated to test this.

The fix uses the third parameter of the `.applySourceMap()` method,
which must be a URL -- a Windows-style path does not cut it. While the
applied source paths should already be URLs (since they come from a
source map, which should be used in browsers), we call `path.dirname()`
on them, which returns Windows-style paths on Windows. Therefore `urix`
is used to convert them back to URLs again.

For consistency, I then went ahead and fixed another issue: Before
adding any sources into the source map, we should convert them to URLs
if they are Windows-style paths. That is as easy as calling `urix` on
each source first. A test has been added for this.