Skip to content

Instantly share code, notes, and snippets.

@isocroft
Created May 19, 2020 16:56
Show Gist options
  • Save isocroft/f2d2f185052a77682a32de70490fb582 to your computer and use it in GitHub Desktop.
Save isocroft/f2d2f185052a77682a32de70490fb582 to your computer and use it in GitHub Desktop.
/** cURL - User Agent String Variations Regex in JS
*
* See: http://www.useragentstring.com/pages/useragentstring.php?name=cURL
* See: https://jonlabelle.com/snippets/view/yaml/browser-user-agent-regular-expressions
*/
; /* Headless UserAgent(s) */
const healessUAs = /\b(Windows-Update-Agent|Microsoft-CryptoAPI|SophosUpdateManager|SophosAgent|Debian APT-HTTP|Ubuntu APT-HTTP|libcurl-agent|libwww-perl|urlgrabber|curl|Wget|OpenBSD ftp|jupdate)(?:[ /](\d+)(?:\.(\d+)(?:\.(\d+))?)?)?/
; /* cURL Headless UserAgent */
const curlUA = /^curl\/((?:\d)\.(?:\d{1,2})(?:\.(?:\d|x))?) \((?:[\-_\w\.]+)\) libcurl(\/| )\1 \(?(?:(SSL|OpenSSL|NSS)\2(\d)\.(\d{1,2})\.\d([a-z]?)(\.\d)?)?\)?(?: (zlib\/(\d)\.(\d)\.(\d)|\(ipv6 enabled\)))?(?: (libidn\/(?:\d)\.(?:\d{1,2})))?(?: (libssh2\/(?:\d)\.(?:\d{1,2})))?$/i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment