Socket
Socket
Sign inDemoInstall

crawler-url-parser

Package Overview
Dependencies
40
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 1.2.3

CHANGELOG

74

crawler-url-parser.js

@@ -56,14 +56,2 @@ const url = require('url');

function isrelative(){
}
function ischild(base,current){
}
function isparent(base,current){
}
function extract(data,sourceUrl){

@@ -121,7 +109,57 @@ let urlMap = new Map();

function getlevel(current,base){
//samelevel,sublevel,uplevel
//if baseurl "sub.domain.com/aaa/bbb/ccc"
// "sub.domain.com/aaa/bbb/" - uplevel
// "sub.domain.com/aaa/ddd/" - samelevel
// "sub.domain.com/aaa/bbb/ccc/ddd" - sublevel
//else
// null
let ret = null ;
let normlizedCurrent = normalizeUrl(current);
let normlizedBase = normalizeUrl(base);
let parsedCurrentUrl = url.parse(normlizedCurrent);
let parsedBaseUrl = url.parse(normlizedBase);
if(parsedCurrentUrl.host==parsedBaseUrl.host){
let cPath = parsedCurrentUrl.pathname;
let bPath = parsedBaseUrl.pathname;
let cCount = cPath.split("/").length -1;
let bCount = bPath.split("/").length -1;
if(cCount!=bCount){
if(cPath.includes(bPath)){
ret = "uplevel";
}
else if(bPath.includes(cPath)){
ret = "sublevel"
}
}
else if(cCount == bCount){
cPath = cPath.replace(/(\/[^\/]*)[\/]?$/,"");
bPath = bPath.replace(/(\/[^\/]*)[\/]?$/,"");
if(cPath == bPath){
return "samelevel";
}
}
}
return ret;
}
function querycount(current){
let ret = 0 ;
let normlizedCurrent = normalizeUrl(current);
let parsedCurrentUrl = url.parse(normlizedCurrent);
if(parsedCurrentUrl.search!=null){
ret = parsedCurrentUrl.search.split("=").length -1;
}
return ret;
}
module.exports.parse = parse;
module.exports.isrelative = isrelative;
module.exports.ischild = ischild;
module.exports.isparent = isparent;
module.exports.extract = extract;
module.exports.getlevel = getlevel;
module.exports.querycount = querycount;

@@ -131,4 +169,8 @@ //for testing purpose

console.log("for testing purpose");
//getlevel("www.domain.com/aaa/bbb/","www.domain.com/aaa/bbb/ccc");
//let res1 = getlevel("sub.domain.com/aaa/bbb/","sub.domain.com/aaa/bbb/ccc");
//let res2 = getlevel("sub.domain.com/aaa/bbb/ccc/ddd","sub.domain.com/aaa/bbb/ccc");
//let res3 = getlevel("sub.domain.com/aaa/bbb/eee","sub.domain.com/aaa/bbb/ccc");
//debugger;
process.exit();
}
{
"name": "crawler-url-parser",
"version": "1.2.2",
"version": "1.2.3",
"description": "An `URL` parser for crawling purpose.",

@@ -48,3 +48,2 @@ "main": "crawler-url-parser.js",

},
"homepage": "https://gitlab.com/mehmet.kozan/crawler-url-parser",
"bugs": {

@@ -56,9 +55,9 @@ "url": "https://gitlab.com/mehmet.kozan/crawler-url-parser/issues",

"type": "git",
"url": "https://gitlab.com/mehmet.kozan/crawler-url-parser.git"
"url": "git://gitlab.com/mehmet.kozan/crawler-url-parser.git"
},
"author": "Mehmet Kozan",
"author": "Mehmet Kozan <mehmet.kozan@live.com>",
"license": "MIT",
"engines": {
"node": "8.2.1"
"node": ">=0.6"
}
}
# crawler-url-parser
> **An `URL` parser for crawling purpose, has more than 200 unit test cases.**
![avatar of crawler-url-parser](https://assets.gitlab-static.net/uploads/-/system/project/avatar/4809017/crawler-url-parser.png)
[![NPM Package](https://img.shields.io/npm/v/crawler-url-parser.svg?style=flat)](https://www.npmjs.org/package/crawler-url-parser)
[![Downloads Total](https://img.shields.io/npm/dt/crawler-url-parser.svg?style=flat)](https://www.npmjs.org/package/crawler-url-parser)
## crawler-url-parser
**An `URL` parser for crawling purpose.**
## Installation

@@ -49,8 +47,6 @@ `npm install crawler-url-parser`

## Test
* check test folder extra usage.
`mocha`
or
`npm test`
`mocha` or `npm test`
* check test folder and quickstart.js for extra usage.
## API
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc