Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix paths

  • Loading branch information...
commit 24b7191420ee118d882d4517a1904bb75c578ac3 1 parent fdd2dc2
@dvv authored
Showing with 9 additions and 5 deletions.
  1. +5 −0 test/test.js
  2. +4 −5 ua.js
View
5 test/test.js
@@ -0,0 +1,5 @@
+'use strict';
+
+var lookup = require('ua').lookup;
+var ua = lookup('Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.94 Safari/534.13');
+console.log(ua);
View
9 ua.js
@@ -37,7 +37,7 @@ function prepare(src) {
var m0 = freemem();
// load prepared JSON
try {
- uatable = JSON.parse(Fs.readFileSync('ua.json', 'utf8'));
+ uatable = JSON.parse(Fs.readFileSync(__dirname + '/ua.json', 'utf8'));
// no prepared JSON. convert from yaml source
} catch(err) {
var raw = require('yamlparser').eval(Fs.readFileSync(src, 'utf8')).test_cases;
@@ -54,7 +54,7 @@ function prepare(src) {
uatable[k] = v;
}
// dump for future reuse
- Fs.writeFileSync('ua.json', JSON.stringify(uatable), 'utf8');
+ Fs.writeFileSync(__dirname + '/ua.json', JSON.stringify(uatable), 'utf8');
console.error('User agent lookup table prepared.');
}
console.error('User agent lookup table loaded.', Math.round((m0-freemem())/1024/1024*100)/100, 'Mb taken');
@@ -67,7 +67,7 @@ function prepare(src) {
*
*/
-function lookup(str, cb) {
+module.exports.lookup = function lookup(str, cb) {
var ua = uatable[str];
if (!ua) {
// need fetch from outside
@@ -84,5 +84,4 @@ function lookup(str, cb) {
*
*/
-prepare('pgts.yaml');
-module.exports = lookup;
+prepare(__dirname + '/pgts.yaml');
Please sign in to comment.
Something went wrong with that request. Please try again.