Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

util.join() doesn't handle absolute path on Windows correctly

オープン
#355 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript
領域
devtools

調査の方向性

lib/util.js の util.join() と util.isAbsolute() から始め、報告された Windows のドライブレター付きパスを reproducer として使用します。両方のエントリポイントが、F:\Projects\... のようなパスをスラッシュで始まるパスとともにどのように扱うかを確認します。絶対 Windows パスが認識され、source-map ローダーパイプライン全体で繰り返し結合されなくなれば完了です。その後、既存のプロジェクトテストを実行します。

索引モデルが issue の本文から書いたものです。

説明

feat

We use the Webpack pipeline on Windows with sass-loader, postcss-loader, and css-loader. Then we found the generated source paths went crazy: F:\Projects\web-project-boilerplate\src\scss\index.scss just becomes F:/Projects/web-project-boilerplate/src/scss/F:/Projects/web-project-boilerplate/src/scss/F:/Projects/web-project-boilerplate/src/scss/index.scss.

As I followed the codebase in the pipeline, I noticed that the sass-loader use relative path, then the postcss-loader and css-loader turn to use absolute path for "sources" field in the sourceMap. In addition, the absolute path on Windows starts with a symbol of the disk driver, e.g. F: in our case. When it comes to sourceMap's util.join(), it only detects absolute path starts with /

https://github.com/mozilla/source-map/blob/c3a8f5a2a4cc7ac5bc6c06bc93745d3c57bd8860/lib/util.js#L228

So it joins multiple paths across the loaders.

Also, the util.isAbsolute doesn't deal with the Windows absolute path as well.

https://github.com/mozilla/source-map/blob/c3a8f5a2a4cc7ac5bc6c06bc93745d3c57bd8860/lib/util.js#L241

Appendix:
Here is a case of how expressjs test the absolute path:

exports.isAbsolute = function(path){
  if ('/' === path[0]) return true;
  if (':' === path[1] && ('\\' === path[2] || '/' === path[2])) return true; // Windows device path
  if ('\\\\' === path.substring(0, 2)) return true; // Microsoft Azure absolute path
};

I'm not sure we need to handle the azure absolute path, but I would be better if we had window device path included.

Thanks

主要言語
JavaScript
スター
3.7k
フォーク
370
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

mozilla/source-map のほかの issue

mozilla/source-map の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。