0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【JavaScript】pathをブラウザで使うために

Posted at
  • Node.js標準のpathライブラリはブラウザに対応していない
  • path-browserifyはブラウザでdirname, extname, parse, joinなどが使える
  • path-browserifyはposixしかサポートしていないため、normalize-pathを使って事前にファイルパスをposix/unix風のパスに正規化する
  • Windowsではスラッシュとバックスラッシュの両方に対応するため、パーソナライズ(正規化の反対)は不要

おまけ: path.joinではスラッシュの違いは修正されない

console.log(path.win32.join("a/b", "c")); // a\b\c
console.log(path.posix.join("a\\b", "c")); // a\b/c
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?