Skip to content

Commit

Permalink
Readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
khalidsalomao committed May 17, 2016
1 parent f7c7c63 commit 2f641ef
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 22 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

All notable changes to this project will be documented in this file.

[unreleased]: https://github.com/khalidsalomao/simple-query-string/compare/1.2.5...HEAD

[unreleased]: https://github.com/khalidsalomao/simple-query-string/compare/1.3.0...HEAD


### [unreleased]

- Performance improvement
- Memory footprint reduced
- Benchmarks to avoid performance regression
- Alternative delimiter: URLs embedded in HTML as https://en.wikipedia.org/wiki/Query_string#Structure
- Improvement in stringify logic for arrays

[v1.3.0]: https://github.com/khalidsalomao/simple-query-string/compare/1.2.5...1.3.0


### [v1.2.5] - 2016-05-14
Expand Down
86 changes: 65 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Utility javascript methods to encode and decode query string parameters with ext


-----

### Installation


Expand Down Expand Up @@ -44,6 +45,7 @@ $ bower install simple-query-string


----

### Features


Expand All @@ -52,6 +54,8 @@ $ bower install simple-query-string

* **fast**

Several benchmarks are run at each release to ensure maximum performance.


* **query string parsing**

Expand All @@ -60,18 +64,18 @@ $ bower install simple-query-string

* **full url** detection

There is no need to use url.split('?')[1] or any other code, just put the entire string!
There is no need to use `url.split('?')[1]` or any other code, just put the entire string!

`simpleQueryString.parse("http://example.org/test/?key=val&param=1")`


* **location.hash** support

`simpleQueryString.parse(location.hash)`


* **location.search** support

`simpleQueryString.parse(location.search)`


Expand All @@ -81,7 +85,7 @@ $ bower install simple-query-string


* **anchor detection**

`simpleQueryString.parse("http://example.org/test/?key=val&param=1#anchor") // #anchor will be ignored`


Expand All @@ -91,7 +95,7 @@ $ bower install simple-query-string
var qs = require('simple-query-string');
var parsed = qs.parse("key=val&param=1");
console.log(parsed["key"]);
console.log(parsed["param"]);
Expand All @@ -104,7 +108,7 @@ $ bower install simple-query-string
<script src="https://cdn.rawgit.com/khalidsalomao/simple-query-string/1.2.5/src/simplequerystring.js"></script>
<script>
var parsed = simpleQueryString.parse("key=val&param=1");
console.log(parsed["key"]);
</script>
```
Expand All @@ -121,13 +125,13 @@ $ bower install simple-query-string
* **`for..in` safe**

Safe to be used in a for in loop. The object is created with `Object.create(null)`.

```
var dic = simpleQueryString.parse("http://example.org/?p1=val&p2=true&p3=3&p4=str");
for (var k in dic) {
console.log(dic[k]);
}
```


Expand All @@ -136,11 +140,20 @@ $ bower install simple-query-string
`simpleQueryString.parse(null) // equals to {}`


* **Custom delimiter**

In some cases, you may want to use another separator instead of ampersand.
Example using semicolon (';') as separator:

`simpleQueryString.parse('p1=a;p2=1', ';') // equals to '{ p1:'a', p2: 1}'`


#### Query String Encoding

* **fast**

Several benchmarks are run at each release to ensure maximum performance.


* **properties detection**

Expand All @@ -163,7 +176,7 @@ $ bower install simple-query-string
var qs = require('simple-query-string');
var str = qs.stringify({ param: 1, p2: true, p3: false });
console.log(str); // equals to 'param=1&p2=true&p3=false'
```
Expand All @@ -175,7 +188,7 @@ $ bower install simple-query-string
<script src="https://cdn.rawgit.com/khalidsalomao/simple-query-string/1.2.5/src/simplequerystring.js"></script>
<script>
var str = simpleQueryString.stringify({ param: 1, p2: true, p3: false });
console.log(str);
</script>
```
Expand All @@ -200,6 +213,12 @@ $ bower install simple-query-string

`simpleQueryString.stringify(null) // equals to ''`

* **Custom delimiter**

In some cases, you may want to use another separator instead of ampersand.
Example using semicolon (';') as separator:

`simpleQueryString.stringify({ p1: 'a', p2: 1 }, ';') // equals to 'p1=a;p2=1'`


### Getting Started
Expand Down Expand Up @@ -252,25 +271,50 @@ $ npm test

#### Browser

##### Install dependencies

```
$ npm install bower -g
$ bower update
```


##### Run tests in browser

Run the tests by opening `./spec/testpage.html`.


-----
### Additional Information

Project generated by [yeoman generator-test](https://github.com/phillipalexander/generator-test):
`yo test`.
### Query string reference

Some documentation for future reference.

[Wikipedia on Query string structure](https://en.wikipedia.org/wiki/Query_string#Structure)

> * The query string is composed of a series of field-value pairs.
> * Within each pair, the field name and value are separated by an equals sign, '='.
> * The series of pairs is separated by the ampersand, '&' (or semicolon, ';' for URLs embedded in HTML and not generated by a `<form>...</form>;` see below).

##### W3C semicolon recommendation

[W3C - Ampersands in URI attribute values](https://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2)


> We recommend that HTTP server implementors, and in particular, CGI implementors support the use of ";" in place of "&" to save authors the trouble of escaping "&" characters in this manner.

##### RFC 3986 on Query component

[RFC 3986](https://tools.ietf.org/html/rfc3986)


Some relevant parts of the documentation for future reference.


https://tools.ietf.org/html/rfc3986#section-3.4

> The query component is indicated by the first question
mark ("?") character and terminated by a number sign ("#") character
or by the end of the URI

https://tools.ietf.org/html/rfc3986#section-4.2

> relative-ref = relative-part [ "?" query ] [ "#" fragment ]

### License
Expand Down

0 comments on commit 2f641ef

Please sign in to comment.