JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 40
  • Score
    100M100P100Q42734F
  • License MIT

URI encoding with support for character encoding.

Package Exports

  • encodeuricharenc

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (encodeuricharenc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

encodeURI.js

NPM

URI encoding with support for character encoding.

There are other URL encoders that supports character encoding but I couldn't find one that honors the Unreserved Characters in RFC 3986.

Uses ES6 features. Has been used with AWS Lambda (v4.3.2).

Install

$ npm install encodeuricharenc

Usage

  var encURI = require('encodeuricharenc');

  // The only encoding for encodeURIComponent() is UTF-8
  var str = "Smörgåsbord";
  var utf8Encoded = encodeURIComponent(str);
  
  // Sometimes you need another encoding
  var iso88591Encoded = encURI(str, 'iso-8859-1');

  console.log(utf8Encoded);     // Sm%C3%B6rg%C3%A5sbord
  console.log(iso88591Encoded); // Sm%F6rg%E5sbord

TODO

  • Decoding
  • Tests