Code Monkey home page Code Monkey logo

decode-uri-component's Introduction

decode-uri-component

CI Coverage Status

A better decodeURIComponent

Why?

  • Converts the BOM to a replacement character .
  • Does not throw with invalid encoded input.
  • Decodes as much of the string as possible.

Install

$ npm install --save decode-uri-component

Usage

import decodeUriComponent from 'decode-uri-component';

decodeUriComponent('%25');
//=> '%'

decodeUriComponent('%');
//=> '%'

decodeUriComponent('st%C3%A5le');
//=> 'ståle'

decodeUriComponent('%st%C3%A5le%');
//=> '%ståle%'

decodeUriComponent('%%7Bst%C3%A5le%7D%');
//=> '%{ståle}%'

decodeUriComponent('%7B%ab%%7C%de%%7D');
//=> '{%ab%|%de%}'

decodeUriComponent('%FE%FF');
//=> '\uFFFD\uFFFD'

decodeUriComponent('%C2');
//=> '\uFFFD'

decodeUriComponent('%C2%B5');
//=> 'µ'

API

decodeUriComponent(encodedURI)

encodedURI

Type: string

An encoded component of a Uniform Resource Identifier.

License

MIT © Sam Verschueren


Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

decode-uri-component's People

Contributors

r-browser-app-team avatar samverschueren avatar void-spark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

decode-uri-component's Issues

"optional catch binding" causes compatibility issue in older browsers

While working on my project, I encountered an "Unexpected token {" error in an Android webview.
This error is caused by the fact that the current version of Chrome (65.0.3325.109) does not support "optional catch binding".
To ensure maximum compatibility, it may be reasonable for this library to add catch binding.
image

Denial of Service (DoS) Reported in SYNK

Hey there, I found this issue while running security scan with SYNK. And, turned out there's a vulnerability. Hopefully there's a way to resolve this issue. Thank you.

Here's the error logs:
Issues with no direct upgrade or patch: ✗ Denial of Service (DoS) [High Severity][https://security.snyk.io/vuln/SNYK-JS-DECODEURICOMPONENT-3149970] in [email protected] introduced by @testing-library/[email protected] > [email protected] > [email protected] > [email protected] and 2 other path(s) No upgrade or patch available

Update breaking slack github actions workflow

Latest updates broke our Github Actions workflow which posts alerts to slack:
Error: web-api:WebClient:0 failed to match all allowed schemas [json-pointer:/blocks/5/text] Error: web-api:WebClient:0 must be less than 3001 characters [json-pointer:/blocks/5/text/text]

TypeError: decodeComponents(...).join is not a function

Crash occured when %ea%ba%5a%ba is parsed by decodeUriComponent

This function is used in some other nodejs projects for decoding query strings and hash strings in url, for example the hash # kun%ea%ba%5a%ba is valid and should be parsed correctly as { ' kun%ea%ba%5a%ba': null }

For example in chrome's development tools' console the url https://google.com# kun%ea%ba%5a%ba can be parsed without problems:

const url = new URL("https://google.com#  kun%ea%ba%5a%ba");
url

image

Code to reproduce

const decodeUriComponent = require('decode-uri-component');

var x = decodeUriComponent('%ea%ba%5a%ba');

console.log(x);

Results

TypeError: decodeComponents(...).join is not a function

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.