1.1.0 • Published 5 months ago

better-decode-uri-component v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

better-decode-uri-component

Safe and maximum possible decodeURIComponent

Installation

npm install better-decode-uri-component

Usage

Browser

<script src="https://cdn.jsdelivr.net/npm/better-decode-uri-component"></script>

ES Modules

import betterDecodeURIComponent from 'better-decode-uri-component';

CommonJS

const betterDecodeURIComponent = require('better-decode-uri-component');

Normal usage (works like standard decodeURIComponent)

betterDecodeURIComponent('Hello%20World'); // "Hello World"

Safely handles malformed sequences

betterDecodeURIComponent('Hello%FF%20World'); // "Hello World"

Maximum possible decoding

betterDecodeURIComponent('%E6%97%A5%FF%E6%9C%AC%E8%AA%9E'); // "日本語"

Keep malformed sequences with removeMalform: false

betterDecodeURIComponent('Hello%FF%20World', { removeMalform: false }); // "Hello%FF World"

Options

betterDecodeURIComponent(str, {
  maxSequenceSize: 4,    // Maximum number of UTF-8 bytes to try decoding at once (default: 4)
  removeMalform: true    // Remove malformed sequences instead of keeping them (default: true)
});

License

MIT

1.1.0

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago