Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detector crashes when parsing invalid URL paths #4

Open
SlayterDev opened this issue Mar 18, 2020 · 0 comments
Open

Detector crashes when parsing invalid URL paths #4

SlayterDev opened this issue Mar 18, 2020 · 0 comments

Comments

@SlayterDev
Copy link
Contributor

There's a case where the crawler may generate data with invalid URLs. When the detector tries to parse the url and save the path the detector will crash. It may be better in this case to make a best effort to pull the path from the URL or at the very least catch the exception so we can continue.

The error occurs in src/trackers/helpers/parseUrl.js:

this.path = new urlParse.URL(url).pathname

My workaround for the time being is this:

try {
    this.path = new urlParse.URL(url).pathname
} catch (e) {
    const comps = url.split('/');
    this.path = comps[comps.length - 1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant