Guest User

Untitled

a guest
Aug 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. ### Testing if the client is a mobile or a desktop.
  2. ### The selection is based on the usual UA strings for desktop browsers.
  3.  
  4. ## Testing a user agent using a method that reverts the logic of the
  5. ## UA detection. Inspired by notnotmobile.appspot.com.
  6. map $http_user_agent $is_desktop {
  7. default 0;
  8. ~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
  9. ~*spider|crawl|slurp|bot 1; # bots
  10. ~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes
  11. }
  12.  
  13. ## Revert the logic.
  14. map $is_desktop $is_mobile {
  15. 1 0;
  16. 0 1;
  17. }
Add Comment
Please, Sign In to add comment