国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

node.js中的url.parse方法使用說明

2019-11-20 13:46:18
字體:
來源:轉載
供稿:網友

方法說明:

講一個URL字符串轉換成對象并返回。

語法:

復制代碼 代碼如下:

url.parse(urlStr, [parseQueryString], [slashesDenoteHost])

接收參數:

urlStr                                       url字符串

parseQueryString                   為true時將使用查詢模塊分析查詢字符串,默認為false

slashesDenoteHost               

默認為false,//foo/bar 形式的字符串將被解釋成 { pathname: ‘//foo/bar' }

如果設置成true,//foo/bar 形式的字符串將被解釋成  { host: ‘foo', pathname: ‘/bar' }

例子:

復制代碼 代碼如下:
var url = require('url');
var a = url.parse('http://example.com:8080/one?a=index&t=article&m=default');
console.log(a);
 
//輸出結果:
{
    protocol : 'http' ,
    auth : null ,
    host : 'example.com:8080' ,
    port : '8080' ,
    hostname : 'example.com' ,
    hash : null ,
    search : '?a=index&t=article&m=default',
    query : 'a=index&t=article&m=default',
    pathname : '/one',
    path : '/one?a=index&t=article&m=default',
    href : 'http://example.com:8080/one?a=index&t=article&m=default'
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 华蓥市| 千阳县| 潜江市| 舞阳县| 永吉县| 韶关市| 阿城市| 肇源县| 武安市| 无棣县| 秭归县| 铜梁县| 乃东县| 榆林市| 雅安市| 铜山县| 塔城市| 玉门市| 古蔺县| 禄劝| 华亭县| 纳雍县| 宜兴市| 临桂县| 府谷县| 大城县| 赫章县| 藁城市| 仙游县| 钟祥市| 昌邑市| 重庆市| 张家界市| 永州市| 万源市| 石柱| 东乡| 孟村| 棋牌| 阿鲁科尔沁旗| 星子县|