๐Ÿ“ฆ robhogan / jsc-safe-url

โ˜… 4 stars โ‘‚ 0 forks ๐Ÿ‘ 4 watching โš–๏ธ Other
๐Ÿ“ฅ Clone https://github.com/robhogan/jsc-safe-url.git
HTTPS git clone https://github.com/robhogan/jsc-safe-url.git
SSH git clone git@github.com:robhogan/jsc-safe-url.git
CLI gh repo clone robhogan/jsc-safe-url
Rob Hogan Rob Hogan Add README b47f886 2 years ago ๐Ÿ“ History
๐Ÿ“‚ b47f88682c6a541d6554f36d118f9c771a666f2b View all commits โ†’
๐Ÿ“ .github
๐Ÿ“„ .gitignore
๐Ÿ“„ index.js
๐Ÿ“„ index.js.flow
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ test.js
๐Ÿ“„ yarn.lock
๐Ÿ“„ README.md

jsc-safe-url

JavaScriptCore santizes source URLs in error stacks by stripping query strings and fragments. Ref: Webkit/Webkit#49109d.

This package contains utility functions required to implement the proposed React Native Community RFC0646. It exports two functons:

function toJscSafeUrl(urlToConvert: string): string

Accepts an absolute or relative URL, and encodes any data in the input query string (if present) into the path component of the URL, by using the reserved character sequence ;& to separate the original path from the orignal query string. Throws if the input cannot be parsed as a URL.

toJscSafeUrl('https://example.com/path?foo=bar#fragment') 
// 'https://example.com/path;&foo=bar#fragment'

function normalizeUrl(urlToNormalize: string): string

Accepts an absolute or relative URL, and replaces the first unencoded ;& in the path component with ?. (Effectively the reverse of toJscSafeUrl.) Throws if the input cannot be parsed as a URL.

normalizeUrl('https://example.com/path;&foo=bar#fragment') 
// 'https://example.com/path?foo=bar#fragment'