wails icon indicating copy to clipboard operation
wails copied to clipboard

Use a user-agent that is more recognizable by front-end code

Open hsiafan opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

Some of lib use userAgent to detect the browser current used, and may write specific code for each type of browsers. A typical code searches for a specific string in userAgent, Ex. 'Edge', 'Firefox', 'Chrome', 'Safari'.

Blow is code fragment from SortableJS,a widely used library for reorderable drag-and-drop lists.

  function userAgent(pattern) {
    if (typeof window !== 'undefined' && window.navigator) {
      return !! /*@__PURE__*/navigator.userAgent.match(pattern);
    }
  }
  var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
  var Edge = userAgent(/Edge/i);
  var FireFox = userAgent(/firefox/i);
  var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
  var IOS = userAgent(/iP(ad|od|hone)/i);

However the userAgent of wails do not contains this words, more specially in my case, it do not contains 'Safari/605.1.15' as Safari browser do.

As a result, SortableJS works perfectly in Safari, but Not working properly in wails' webview.

Describe the solution you'd like

Default userAgent like a normal browser do, something like 'Safari/605.1.15' under Under macos.

Describe alternatives you've considered

Allow use to set a userAgent or append a part to default userAgent.

Additional context

No response

hsiafan avatar Jan 31 '24 04:01 hsiafan

Can look into setting custom values, but SortableJS is going to need to be updated anyway: edge now reports the user agent string Edg/<version> instead of Edge/<version>: https://stackoverflow.com/a/77234353

leaanthony avatar Jan 31 '24 06:01 leaanthony