Socket
Book a DemoInstallSign in
Socket

@tongdun/utils-url

Package Overview
Dependencies
Maintainers
5
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@tongdun/utils-url

URL前端处理工具

1.0.1
unpublished
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
5
Weekly downloads
 
Created
Source

@tongdun/utils-url

前端对url的基本处理方法

npm package NPM downloads

API

parseURL(url)

把url的所有信息转化成json对象

  • request
字段类型是否可以为空说明
urlstringyesurl默认值是window.location.href
'http://localhost:8080/a/b/c?a=1&b=2#abc'
  • response
{
  "source": "http://localhost:8080/a/b/c?a=1&b=2#abc",
  "protocol": "http",
  "hostname": "localhost",
  "port": "8080",
  "search": "?a=1&b=2",
  "origin": "http://localhost:8080",
  "params": {
    "a": "1",
    "b": "2"
  },
  "file": "c",
  "hash": "#abc",
  "hashName": "abc",
  "pathname": "/a/b/c",
  "originPath": "http://localhost:8080/a/b/c",
  "relative": "/a/b/c?a=1&b=2#abc",
  "segments": [
    "a",
    "b",
    "c"
  ]
}

getParams(url)

把url的参数部分转化成json对象

  • request
字段类型是否可以为空说明
urlstringyesurl默认值是window.location.href
'http://localhost:8080/a/b/c?a=1&b=2#abc'
  • response
{
  "a": "1",
  "b": "2"
}

getParam(key, url)

通过key获取url中的参数值

  • request
字段类型是否可以为空说明
keystringno
urlstringyesurl默认值是window.location.href
'a'
'http://localhost:8080/a/b/c?a=1&b=2#abc'
  • response
1

appendParam(key, value, url)

向url中添加参数

  • request
字段类型是否可以为空说明
keystringno
valueallyes
urlstringyesurl默认值是window.location.href
'a'
'b'
'http://localhost:8080/a/b/c?a=1&b=2#abc'
  • response
'http://localhost:8080/a/b/c?a=b&b=2#abc'

appendParams(params, url)

向url中添加多个参数

  • request
字段类型是否可以为空说明
paramsobjectno
urlstringyesurl默认值是window.location.href
{"ssq":1111}
'http://localhost:8080/a/b/c?a=1&b=2#abc'
  • response
'http://localhost:8080/a/b/c?a=1&b=2&ssq=1111#abc'

removeParams(arr, url)

功能:向url中去除多个参数

  • request
字段类型是否可以为空说明
paramsarrayno
urlstringyesurl默认值是window.location.href
["a", "b" ]
'http://localhost:8080/a/b/c?a=1&b=2#abc'
  • response
'http://localhost:8080/a/b/c#abc'

Keywords

utils

FAQs

Package last updated on 13 Aug 2018

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.