node.js中的url.parse方法使用說明
方法說明:
講一個URL字符串轉(zhuǎn)換成對象并返回。
語法:
url.parse(urlStr, [parseQueryString], [slashesDenoteHost])
接收參數(shù):
urlStr url字符串
parseQueryString 為true時將使用查詢模塊分析查詢字符串,默認為false
slashesDenoteHost
默認為false,//foo/bar 形式的字符串將被解釋成 { pathname: ‘//foo/bar' }
如果設(shè)置成true,//foo/bar 形式的字符串將被解釋成 { host: ‘foo', pathname: ‘/bar' }
例子:
var a = url.parse('http://example.com:8080/one?a=index&t=article&m=default');
console.log(a);
//輸出結(jié)果:
{
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'
}
相關(guān)文章
node.js中fs.stat與fs.fstat的區(qū)別詳解
fs.stat和fs.fstat他們都是用來獲取文件的狀態(tài)信息,下面這篇文章主要給大家介紹了關(guān)于node.js中fs.stat與fs.fstat區(qū)別的相關(guān)資料,文中介紹的非常詳細,對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。2017-06-06Node.js中MongoDB更新數(shù)據(jù)的兩種方法
本文主要介紹了Node.js中MongoDB更新數(shù)據(jù)的兩種方法,主要包括使用原生的 MongoDB 驅(qū)動程序或者使用 Mongoose 來更新 MongoDB 數(shù)據(jù),2023-12-12一文教你學(xué)會Nodejs中puppeteer的簡單使用
Puppeteer是一個控制headless Chrome的Node.js API ,是一個 Node.js庫,在瀏覽器中手動完成的大多數(shù)事情都可以通過使用 Puppeteer完成,本文主要介紹了Puppeteer的簡單使用,希望對大家有所幫助2024-01-01node?gyp安裝canvas原生模塊編譯node?pregyp詳解
這篇文章主要為大家介紹了Nodejs關(guān)于原生模塊編譯node-gyp + node-pre-gyp (以安裝canvas為例)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-11-11