Package Exports
- form-urlencoded
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 (form-urlencoded) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
form-urlencoded
(c)Bumblehead,JBlashill 2013,2014 MIT-license
OVERVIEW:
form-urlencoded encodes x-www-form-urlencoded
string data. It may be used in an ecmascript environment, such as a browser or node.js.
application/x-www-form-urlencoded
is a string encoding used, primarily, when an HTML form is submitted. The form data is serialised in this format and sent to a server.
The format is not well defined. Serialising complex data, such as a javascript object, is beyond the specification.
Server softwares do share methods for handling complex urlencoded data and so there is a "defacto" standard for serializing such data. This is the standard that form-urlencoded follows.
INSTALL:
form-urlencoded may be downloaded directly or installed through npm
.
npm
$ npm install form-urlencoded
to run tests, use npm test
from a shell.
$ npm test
encode:
var formurlencoded = require('form-urlencoded');
var obj = {
propStr1 : 'str1',
propStr2 : 'str2',
propStr3 : 'str2',
propArr : [3, { prop : 'val' }, 1, null, 6],
propObj : {
objPropStr1 : 'objStr1',
objPropStr2 : null
}
};
console.log(formurlencoded.encode(obj));
// propStr1=str1&propStr2=str2&propStr3=str2&propArr%5B%5D=
// 3&propArr%5B%5D%5Bprop%5D=val&propArr%5B%5D=1&propArr%5B
// %5D=null&propArr%5B%5D=6&propObj%5BobjPropStr1%5D=objStr
// 1&propObj%5BobjPropStr2%5D=null
console.log(formurlencoded.encode(obj, {
ignorenull : true,
sorted : true
}));
// propArr%5B%5D=3&propArr%5B%5D%5Bprop%5D=val&propArr%5B%5
// D=1&propArr%5B%5D=6&propObj%5BobjPropStr1%5D=objStr1&pro
// pStr1=str1&propStr2=str2&propStr3=str2
License:
(The MIT License)
Copyright (c) 2012 Bumblehead chris@bumblehead.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.