๐Ÿ“ฆ 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 Bump to 0.2.4 9b00f65 2 years ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“„ .flowconfig
๐Ÿ“„ .gitignore
๐Ÿ“„ index.d.ts
๐Ÿ“„ index.js
๐Ÿ“„ 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 three functons:

function isJscSafeUrl(url: string): boolean

Returns false if the URL has a query component that could be stripped by JSC.

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 delimiter //& (which cannot appear in a normalized file path) to separate the original path from the orignal query string.

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

function toNormalUrl(urlToNormalize: string): string

Accepts an absolute or relative URL, and replaces the first unescaped //& in the path component with ?. (Effectively the reverse of toJscSafeUrl.)

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