node中url的使用
来源:互联网 发布:自动化设计软件 编辑:程序博客网 时间:2024/06/05 02:32
一. .parse方法来将一个URL字符串转换为URL对象:
url.parse('http://user:pass@host.com:8080/p/a/t/h?query=string#hash');/* =>{ protocol: 'http:', auth: 'user:pass', host: 'host.com:8080', port: '8080', hostname: 'host.com', hash: '#hash', search: '?query=string', query: 'query=string', pathname: '/p/a/t/h', path: '/p/a/t/h?query=string', href: 'http://user:pass@host.com:8080/p/a/t/h?query=string#hash' }*/
.parse方法还支持第二个和第三个布尔类型可选参数。第二个参数等于true时,该方法返回的URL对象中,query字段不再是一个字符串,而是一个经过querystring模块转换后的参数对象。第三个参数等于true时,该方法可以正确解析不带协议头的URL,例如//www.example.com/foo/bar
二. format方法允许将一个URL对象转换为URL字符串
url.format({ protocol: 'http:', host: 'www.example.com', pathname: '/p/a/t/h', search: 'query=string'});/* =>'http://www.example.com/p/a/t/h?query=string'*/
三. .resolve方法可以用于拼接URL
url.resolve('http://www.example.com/foo/bar', '../baz');/* =>http://www.example.com/baz*/
1 0
- node中url的使用
- Node中url模块的使用
- Node.js中URL的解析
- node(url使用)
- node的URL
- node.js url 模块使用时的小trick
- JAVA中URL的使用
- Java中URL的使用
- java中URL的使用
- Node.js中async的简单使用
- node.js中mysql的简单使用
- Node.js中http-server的使用
- Node.js中Mysql的使用
- node.js使用url下载文件
- node * 和 node **的使用
- Node 中使用 supervisor
- node中使用session
- .net中URL路径的基本使用
- sap 中怎样把非限制库存转为销售订单库存?
- 关于 Android System Properties
- unsigned , NSInteger/NSUInter ,NSNumber,
- Runnable或Callable的比较
- Android滑动侧边栏
- node中url的使用
- 苦逼的IT生涯产生原因
- MB1A MB1B MB1C MB11 MIGO的区别解析
- 启动Fragment,进入一个activity完成逻辑后回到这个Fragment,更新代码在onResume中
- 策略模式
- Android webview网页视频无法全屏解决(onShowCustomView不调用)
- Dom4j创建XML,解析XML
- SAP ABAP收货或者货物移动(MIGO,MB11,MB1A)在保存时候的增强点
- swift创建一个空项目