Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Conversation

@mgreter
Copy link
Contributor

@mgreter mgreter commented Jul 26, 2014

This is related to #441 and #242

Source Maps currently contain invalid paths:

"sources": ["../../../../../D:\github\webmerge\example\scss\_QfHU8qB_K.scss" ]

I tracked down the cultprit (as did #441) to be in resolve_relative_path. But IMO the underlying problem is burried deeper in the code at context.cpp#L288. resolve_relative_path is called with real_path from resolve_and_load (uri), source_map_file (base) and cwd (cwd) (file.cpp#L85):

 uri: D:\github\webmerge\example\scss\4CTIC43Arz.scss
 base: test.map
 cwd: D:/github/webmerge/example/scss/
 absolute_uri: D:\github\webmerge\example\scss\4CTIC43Arz.scss
 absolute_base: D:/github/webmerge/example/scss/test.map
 => ../../../../../D:\github\webmerge\example\scss\4CTIC43Arz.scss

I also have done some additional tests for when resolve_relative_path is called with a base on a different drive (after applying this patch). It will then return a full windows path with forward slashes (which is acceptable IMO).

D:/github/webmerge/example/scss/4CTIC43Arz.scss

I don't know why #441 wants to actually convert paths on windows to lowercase. I think this would lead to all paths in source maps to be in lowercase. Which would introduce problems if these files would be deployed to linux or any other case sensitive fs.

It also fixes #242 since it should now always produce forward slashes, which do not need to be escaped. Although source_map.cpp#L14 definitely should use some proper escaping.

mgreter added 2 commits July 26, 2014 07:03
Replace back slashes with forward slashes on windows.
Since get_cwd is normalized the same way, we need to
normalize this path too. Otherwise resolve_relative_path
will not work correctly on windows.
@am11
Copy link
Contributor

am11 commented Jul 28, 2014

@mgreter, can you please confirm if fixes made by #441 overlap this? It turned out to be the issue with lower-case. I think this will compliment those fixes. But in any case please review it.

If you think my fixes needs to be reverted after this, please do so. I was actually testing with node-sass code. I think node-sass sends at-least one path differently (don't remember off-hand, can confirm if you want).

The end result is to have network-accessible relative-paths in the entire source-map.

Thanks! :)

akhleung pushed a commit that referenced this pull request Jul 28, 2014
Problem with relative path on windows and source maps
@akhleung akhleung merged commit ab3a9ee into sass:master Jul 28, 2014
@mgreter mgreter deleted the source_maps_win_rel_paths branch October 5, 2014 20:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SourceMap - Producing invalid JSON

3 participants