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

Bot parser superfluous behavior #5698

Closed
wazelin opened this issue Jan 15, 2018 · 0 comments
Closed

Bot parser superfluous behavior #5698

wazelin opened this issue Jan 15, 2018 · 0 comments

Comments

@wazelin
Copy link
Contributor

wazelin commented Jan 15, 2018

It seems like discardDetails option doesn't work as descibed here.
It still performs walk through the array of bot regexes when set to true.

Shouldn't this part of \DeviceDetector\Parser\Bot::parse() method

if ($this->preMatchOverall()) {
    foreach ($this->getRegexes() as $regex) {
        $matches = $this->matchUserAgent($regex['regex']);
        if ($matches) {
            if ($this->discardDetails) {
                $result = true;
                break;
            }
            unset($regex['regex']);
            $result = $regex;
            break;
        }
    }
}

be something like this instead?

if ($this->preMatchOverall()) {
    if ($this->discardDetails) {
        $result = true;
    } else {
        foreach ($this->getRegexes() as $regex) {
            $matches = $this->matchUserAgent($regex['regex']);
            if ($matches) {
                unset($regex['regex']);
                $result = $regex;
                break;
            }
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants