Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 87a49d7a0cfc7d0f3ce5ae98407638a8b20266af @hughsk hughsk committed Dec 13, 2012
Showing with 9,834 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 .npmignore
  3. +18 −0 LICENSE.md
  4. +40 −0 README.md
  5. +11 −0 index.js
  6. +29 −0 package.json
  7. +1 −0 regex.js
  8. +9,274 −0 test/browser-agents.js
  9. +442 −0 test/spider-agents.js
  10. +17 −0 test/test.js
@@ -0,0 +1 @@
+node_modules
@@ -0,0 +1 @@
+test
@@ -0,0 +1,18 @@
+This software is released under the MIT license:
+
+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.
@@ -0,0 +1,40 @@
+# funnelweb #
+
+Tries to detect if a request is coming from a machine or a person using a
+regular expression. Bot and browser `User-Agent` strings sourced from
+[useragentstring.com](http://www.useragentstring.com/pages/useragentstring.php).
+
+## Installation ##
+
+``` bash
+$ npm install funnelweb
+```
+
+## Usage ##
+
+Funnelweb just takes a user agent string and returns "true" if it's probably a bot, or "false" otherwise.
+
+``` javascript
+var funnelweb = require('funnelweb')
+
+funnelweb('GoogleBot') // true
+funnelweb('Google Chrome') // false
+```
+
+If you pass it an HTTP request object, it'll read the User-Agent header and do
+the same:
+
+``` javascript
+var funnelweb = require('funnelweb')
+ , http = require('http')
+
+http.createServer(function(req, res) {
+ var response = funnelweb(req)
+
+ if (bot) {
+ res.end('you are a bot')
+ } else {
+ res.end('you are not a bot')
+ }
+}).listen(3000)
+```
@@ -0,0 +1,11 @@
+var regex = require('./regex')
+
+module.exports = function funnelweb(string) {
+ if (typeof string === 'object') {
+ return module.exports(string.headers['User-Agent'] || string.headers['user-agent'])
+ }
+ string += ''
+ return !!string.match(regex)
+};
+
+module.exports.regex = regex
@@ -0,0 +1,29 @@
+{
+ "name": "funnelweb",
+ "version": "0.0.1",
+ "description": "Detect search engine crawlers by their User-Agent strings.",
+ "main": "index.js",
+ "scripts": {
+ "test": "node_modules/.bin/mocha -u tdd --reporter dot"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/presentcompany/funnelweb.git"
+ },
+ "keywords": [
+ "search",
+ "engine",
+ "user",
+ "agent",
+ "crawler",
+ "spider"
+ ],
+ "author": "Present Company <hello@presentcompany.co> (http://presentcompany.co)",
+ "maintainers": [
+ "Hugh Kennedy <hughskennedy@gmail.com> (http://hughskennedy.com/"
+ ],
+ "license": "MIT",
+ "devDependencies": {
+ "mocha": "~1.7.4"
+ }
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 87a49d7

Please sign in to comment.