Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Added wkhtmltopdf detection
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbull committed Dec 28, 2016
1 parent bf61277 commit e1bee47
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 6.1.2 (released 2016-12-13)

- Added wkhtmltopdf detection

## 6.1.1 (released 2016-12-13)

- Added Samsung Browser detection
Expand Down
1 change: 1 addition & 0 deletions src/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Browser
const MOZILLA = 'Mozilla';
const AMAYA = 'Amaya';
const LYNX = 'Lynx';
const WKHTMLTOPDF = 'wkhtmltopdf';
const SAFARI = 'Safari';
const SAMSUNG_BROWSER = 'SamsungBrowser';
const CHROME = 'Chrome';
Expand Down
16 changes: 16 additions & 0 deletions src/BrowserDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class BrowserDetector implements DetectorInterface
'Gsa',
// common bots
'Robot',
// wkhtmltopdf before Safari
'Wkhtmltopdf',
// WebKit base check (post mobile and others)
'Safari',
// everyone else
Expand Down Expand Up @@ -899,6 +901,20 @@ public static function checkBrowserAmaya()
return false;
}

/**
* Determine if the browser is Safari.
*
* @return bool
*/
public static function checkBrowserWkhtmltopdf()
{
if (stripos(self::$userAgentString, 'wkhtmltopdf') !== false) {
self::$browser->setName(Browser::WKHTMLTOPDF);
return true;
}

return false;
}
/**
* Determine if the browser is Safari.
*
Expand Down
11 changes: 11 additions & 0 deletions tests/BrowserDetector/Tests/_files/UserAgentStrings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,16 @@
Mozilla/5.0 (Linux; Android 5.1.1; SAMSUNG SM-G360T1 Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/3.3 Chrome/38.0.2125.102 Mobile Safari/537.36
</field>
</string>
<string>
<field name="browser">wkhtmltopdf</field>
<field name="version">unknown</field>
<field name="os">Linux</field>
<field name="os_version">unknown</field>
<field name="device">unknown</field>
<field name="device_version">unknown</field>
<field name="string">
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) wkhtmltopdf-amd64 Safari/534.34
</field>
</string>
</strings>
</document>

0 comments on commit e1bee47

Please sign in to comment.