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

Commit e1bee47

Browse files
committed
Added wkhtmltopdf detection
1 parent bf61277 commit e1bee47

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 6.1.2 (released 2016-12-13)
4+
5+
- Added wkhtmltopdf detection
6+
37
## 6.1.1 (released 2016-12-13)
48

59
- Added Samsung Browser detection

src/Browser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Browser
2525
const MOZILLA = 'Mozilla';
2626
const AMAYA = 'Amaya';
2727
const LYNX = 'Lynx';
28+
const WKHTMLTOPDF = 'wkhtmltopdf';
2829
const SAFARI = 'Safari';
2930
const SAMSUNG_BROWSER = 'SamsungBrowser';
3031
const CHROME = 'Chrome';

src/BrowserDetector.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class BrowserDetector implements DetectorInterface
5353
'Gsa',
5454
// common bots
5555
'Robot',
56+
// wkhtmltopdf before Safari
57+
'Wkhtmltopdf',
5658
// WebKit base check (post mobile and others)
5759
'Safari',
5860
// everyone else
@@ -899,6 +901,20 @@ public static function checkBrowserAmaya()
899901
return false;
900902
}
901903

904+
/**
905+
* Determine if the browser is Safari.
906+
*
907+
* @return bool
908+
*/
909+
public static function checkBrowserWkhtmltopdf()
910+
{
911+
if (stripos(self::$userAgentString, 'wkhtmltopdf') !== false) {
912+
self::$browser->setName(Browser::WKHTMLTOPDF);
913+
return true;
914+
}
915+
916+
return false;
917+
}
902918
/**
903919
* Determine if the browser is Safari.
904920
*

tests/BrowserDetector/Tests/_files/UserAgentStrings.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,16 @@
263263
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
264264
</field>
265265
</string>
266+
<string>
267+
<field name="browser">wkhtmltopdf</field>
268+
<field name="version">unknown</field>
269+
<field name="os">Linux</field>
270+
<field name="os_version">unknown</field>
271+
<field name="device">unknown</field>
272+
<field name="device_version">unknown</field>
273+
<field name="string">
274+
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) wkhtmltopdf-amd64 Safari/534.34
275+
</field>
276+
</string>
266277
</strings>
267278
</document>

0 commit comments

Comments
 (0)