最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

node.js中的path.normalize方法使用說(shuō)明

 更新時(shí)間:2014年12月08日 11:56:58   投稿:junjie  
這篇文章主要介紹了node.js中的path.normalize方法使用說(shuō)明,本文介紹了path.normalize的方法說(shuō)明、語(yǔ)法、使用實(shí)例和實(shí)現(xiàn)源碼,需要的朋友可以參考下

方法說(shuō)明:

輸出規(guī)范格式的path字符串。

語(yǔ)法:

復(fù)制代碼 代碼如下:

path.normalize(p)

由于該方法屬于path模塊,使用前需要引入path模塊(var path= require(“path”) )

例子:

復(fù)制代碼 代碼如下:

path.normalize('/foo/bar//baz/asdf/quux/..')
// returns
'/foo/bar/baz/asdf'

源碼:

復(fù)制代碼 代碼如下:

// windows version
  exports.normalize = function(path) {
    var result = splitDeviceRe.exec(path),
        device = result[1] || '',
        isUnc = device && device.charAt(1) !== ':',
        isAbsolute = exports.isAbsolute(path),
        tail = result[3],
        trailingSlash = /[\\\/]$/.test(tail);
 
    // If device is a drive letter, we'll normalize to lower case.
    if (device && device.charAt(1) === ':') {
      device = device[0].toLowerCase() + device.substr(1);
    }
 
    // Normalize the tail path
    tail = normalizeArray(tail.split(/[\\\/]+/).filter(function(p) {
      return !!p;
    }), !isAbsolute).join('\\');
 
    if (!tail && !isAbsolute) {
      tail = '.';
    }
    if (tail && trailingSlash) {
      tail += '\\';
    }
 
    // Convert slashes to backslashes when `device` points to an UNC root.
    // Also squash multiple slashes into a single one where appropriate.
    if (isUnc) {
      device = normalizeUNCRoot(device);
    }
 
    return device + (isAbsolute ? '\\' : '') + tail;
  };

相關(guān)文章

最新評(píng)論

耿马| 蒙城县| 神木县| 沁源县| 成武县| 勃利县| 桐城市| 辽阳县| 临西县| 巴南区| 阜宁县| 清原| 安顺市| 古浪县| 华安县| 历史| 磐安县| 大方县| 左云县| 连州市| 神池县| 南汇区| 上蔡县| 阜平县| SHOW| 商都县| 淳安县| 临海市| 崇左市| 昭苏县| 托里县| 盐津县| 略阳县| 昌都县| 理塘县| 常德市| 麻城市| 蕉岭县| 漳州市| 临沂市| 安岳县|