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

@yorkjs/url

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yorkjs/url

parse and stringify url

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

url

整合 url 常用的工具方法。

安装

CDN

<script src="https://unpkg.com/@yorkjs/url"></script>
<script>
  Url.parseUrl(location.href)
</script>

NPM

npm install @yorkjs/url
import Url from '@yorkjs/url'
Url.parseUrl(location.href)

YARN

yarn add @yorkjs/url
import Url from '@yorkjs/url'
Url.parseUrl(location.href)

API

parseUrl(urlStr)

把 url 字符串解析成对象,对象格式如下:

{
  protocol: string
  hostname: string
  port: string
  pathname: string
  search: string
  hash: string
}

stringifyUrl(urlObject)

把 url 对象(格式如上)序列化成字符串。

parseHash(hashStr)

把 hash 字符串(不能有开头的 #)解析成对象,对象格式如下:

{
  pathname: string
  search: string
}

此方法常用于单页应用的 hash mode。

stringifyHash(hashObject)

把 hash 对象(格式如上)序列化成字符串,不包含开头的 #

此方法常用于单页应用的 hash mode。

parseQuery(queryStr)

把 query 字符串(不能有开头的 ?)解析成对象。

stringifyQuery(queryObject)

把 query 对象序列化成字符串,不包含开头的 ?

兼容性

全平台适用,但需要确认以下函数是否存在:

String.prototype.trim
Array.isArray

如不存在,请自行打补丁。

Keywords

FAQs

Package last updated on 26 May 2021

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