Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

httpurl

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpurl

解析URL

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-38.46%
Maintainers
1
Weekly downloads
 
Created
Source

lib-httpurl

基本的URL操作,支持设置和改变URL参数。

安装依赖

运行 npm install,来安装所需的依赖模块。关于NPM的知识,请参见nodejs;

用Grunt打包

运行 grunt,来对项目进行打包。关于Grunt的知识,请参见gruntjs;

如何使用

创建一个实例

var url = new lib.httpurl('//m.taobao.com?ttid=201301@taobao_iphone_3.4.5');
console.log(url.toString());

> http://m.taobao.com?ttid=201301@taobao_iphone_3.4.5

实例的属性和方法

  • protocol - 协议头
  • username - 用户名
  • password - 密码
  • hostname - 主机名
  • port - 端口
  • pathname - 路径
  • search - 查询串
  • hash - 锚点串
  • params - 查询串的键值对

通过params属性获取或修改查询串

url.params.ttid;
> 201301@taobao_iphone_3.4.5

url.params.ttid = '12tx0065';
> 12tx0065

url.params = {ttid:'12tx0065', refid:'qwer'};
console.log(url.search)
> ttid=12tx0065&refid=qwer

Keywords

FAQs

Package last updated on 05 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc