代码改变世界

node.js 模块之url和querystring模块

2014-09-03 22:24  youxin  阅读(360)  评论(0编辑  收藏  举报

关系如下:

                       url.parse(string).query
                                           |
           url.parse(string).pathname      |
                       |                   |
                       |                   |
                     ------ -------------------
http://localhost:8888/start?foo=bar&hello=world
                                ---       -----
                                 |          |
                                 |          |
              querystring(string)["foo"]    |
                                            |
                         querystring(string)["hello"]


pathname不包括query string,

http://localhost:8888/start
的pathname为/start.注意有斜线。
访问http://localhost:8888
的pathname为/.