[Pkg-javascript-commits] [node-media-typer] 03/05: Imported Upstream version 0.3.0

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sat Oct 11 19:19:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-media-typer.

commit 5fa5e29b0ea903641617798661491a057463de59
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Sat Oct 11 19:12:59 2014 +0000

    Imported Upstream version 0.3.0
---
 .npmignore   |  3 ---
 .travis.yml  |  8 ++++++--
 HISTORY.md   |  6 ++++++
 LICENSE      | 22 ++++++++++++++++++++++
 README.md    | 43 ++++++++++++++++++-------------------------
 index.js     |  9 +++++++++
 package.json | 21 +++++++++++++--------
 test/test.js |  6 ++++++
 8 files changed, 80 insertions(+), 38 deletions(-)

diff --git a/.npmignore b/.npmignore
deleted file mode 100644
index cd39b77..0000000
--- a/.npmignore
+++ /dev/null
@@ -1,3 +0,0 @@
-coverage/
-test/
-.travis.yml
diff --git a/.travis.yml b/.travis.yml
index 1ff243c..f034de0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,6 @@
 language: node_js
 node_js:
+  - "0.6"
   - "0.8"
   - "0.10"
   - "0.11"
@@ -7,5 +8,8 @@ matrix:
   allow_failures:
     - node_js: "0.11"
   fast_finish: true
-script: "npm run-script test-travis"
-after_script: "npm install coveralls at 2.10.0 && cat ./coverage/lcov.info | coveralls"
+script:
+  - "test $TRAVIS_NODE_VERSION != '0.6' || npm test"
+  - "test $TRAVIS_NODE_VERSION  = '0.6' || npm run-script test-travis"
+after_script:
+  - "test $TRAVIS_NODE_VERSION = '0.10' && npm install coveralls at 2 && cat ./coverage/lcov.info | coveralls"
diff --git a/HISTORY.md b/HISTORY.md
index 215cc22..62c2003 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,3 +1,9 @@
+0.3.0 / 2014-09-07
+==================
+
+  * Support Node.js 0.6
+  * Throw error when parameter format invalid on parse
+
 0.2.0 / 2014-06-18
 ==================
 
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b7dce6c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+(The MIT License)
+
+Copyright (c) 2014 Douglas Christopher Wilson
+
+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.
diff --git a/README.md b/README.md
index 338b7ce..d8df623 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
 # media-typer
 
-[![NPM version](https://badge.fury.io/js/media-typer.svg)](https://badge.fury.io/js/media-typer)
-[![Build Status](https://travis-ci.org/expressjs/media-typer.svg?branch=master)](https://travis-ci.org/expressjs/media-typer)
-[![Coverage Status](https://img.shields.io/coveralls/expressjs/media-typer.svg?branch=master)](https://coveralls.io/r/expressjs/media-typer)
+[![NPM Version][npm-image]][npm-url]
+[![NPM Downloads][downloads-image]][downloads-url]
+[![Node.js Version][node-version-image]][node-version-url]
+[![Build Status][travis-image]][travis-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
 
 Simple RFC 6838 media type parser
 
@@ -47,7 +49,7 @@ Parse the `content-type` header from the given `req`. Short-cut for
 ### typer.parse(res)
 
 ```js
-var obj = typer.parse(req)
+var obj = typer.parse(res)
 ```
 
 Parse the `content-type` header set on the given `res`. Short-cut for
@@ -65,24 +67,15 @@ documentation for `typer.parse(string)`.
 
 ## License
 
-The MIT License (MIT)
-
-Copyright (c) 2014 Douglas Christopher Wilson
-
-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.
+[MIT](LICENSE)
+
+[npm-image]: https://img.shields.io/npm/v/media-typer.svg?style=flat
+[npm-url]: https://npmjs.org/package/media-typer
+[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat
+[node-version-url]: http://nodejs.org/download/
+[travis-image]: https://img.shields.io/travis/jshttp/media-typer.svg?style=flat
+[travis-url]: https://travis-ci.org/jshttp/media-typer
+[coveralls-image]: https://img.shields.io/coveralls/jshttp/media-typer.svg?style=flat
+[coveralls-url]: https://coveralls.io/r/jshttp/media-typer
+[downloads-image]: https://img.shields.io/npm/dm/media-typer.svg?style=flat
+[downloads-url]: https://npmjs.org/package/media-typer
diff --git a/index.js b/index.js
index cbf2e17..07f7295 100644
--- a/index.js
+++ b/index.js
@@ -164,6 +164,11 @@ function parse(string) {
   paramRegExp.lastIndex = index
 
   while (match = paramRegExp.exec(string)) {
+    if (match.index !== index) {
+      throw new TypeError('invalid parameter format')
+    }
+
+    index += match[0].length
     key = match[1].toLowerCase()
     value = match[2]
 
@@ -177,6 +182,10 @@ function parse(string) {
     params[key] = value
   }
 
+  if (index !== -1 && index !== string.length) {
+    throw new TypeError('invalid parameter format')
+  }
+
   obj.parameters = params
 
   return obj
diff --git a/package.json b/package.json
index be2b2f0..8cf3ebc 100644
--- a/package.json
+++ b/package.json
@@ -1,21 +1,26 @@
 {
   "name": "media-typer",
   "description": "Simple RFC 6838 media type parser and formatter",
-  "version": "0.2.0",
+  "version": "0.3.0",
   "author": "Douglas Christopher Wilson <doug at somethingdoug.com>",
   "license": "MIT",
-  "repository": "expressjs/media-typer",
+  "repository": "jshttp/media-typer",
   "devDependencies": {
-    "istanbul": "0.2.10",
-    "mocha": "~1.20.1",
+    "istanbul": "0.3.2",
+    "mocha": "~1.21.4",
     "should": "~4.0.4"
   },
+  "files": [
+    "LICENSE",
+    "HISTORY.md",
+    "index.js"
+  ],
   "engines": {
-    "node": ">= 0.8.0"
+    "node": ">= 0.6"
   },
   "scripts": {
-    "test": "mocha --reporter dot test/",
-    "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/",
-    "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec test/"
+    "test": "mocha --reporter spec --check-leaks --bail test/",
+    "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
+    "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
   }
 }
diff --git a/test/test.js b/test/test.js
index 7126eb0..695352d 100644
--- a/test/test.js
+++ b/test/test.js
@@ -167,6 +167,12 @@ describe('typer.parse(string)', function () {
     })
   })
 
+  it('should throw on invalid parameter format', function () {
+    typer.parse.bind(null, 'text/plain; foo="bar').should.throw(/invalid parameter format/)
+    typer.parse.bind(null, 'text/plain; profile=http://localhost; foo=bar').should.throw(/invalid parameter format/)
+    typer.parse.bind(null, 'text/plain; profile=http://localhost').should.throw(/invalid parameter format/)
+  })
+
   it('should require argument', function () {
     typer.parse.should.throw(/string.*required/)
   })

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-media-typer.git



More information about the Pkg-javascript-commits mailing list