Use a safe but sane device name

pull/14502/head
J. Ryan Stinnett 2 years ago
parent f70f3c7796
commit 0fa2941188
  1. 29
      src/vector/platform/WebPlatform.ts

@ -173,20 +173,21 @@ export default class WebPlatform extends VectorBasePlatform {
}
getDefaultDeviceDisplayName(): string {
return "unknown browser " + Math.round(Number.MAX_SAFE_INTEGER * Math.random());
// strip query-string and fragment from uri
const u = url.parse(window.location.href);
u.protocol = "";
u.search = "";
u.hash = "";
// Remove trailing slash if present
u.pathname = u.pathname.replace(/\/$/, "");
let appName = u.format();
// Remove leading slashes if present
appName = appName.replace(/^\/\//, "");
// `appName` is now in the format `develop.element.io`.
// TODO: Revert this after launch
// // strip query-string and fragment from uri
// const u = url.parse(window.location.href);
// u.protocol = "";
// u.search = "";
// u.hash = "";
// // Remove trailing slash if present
// u.pathname = u.pathname.replace(/\/$/, "");
// let appName = u.format();
// // Remove leading slashes if present
// appName = appName.replace(/^\/\//, "");
// // `appName` is now in the format `develop.element.io`.
const appName = "Riot Web";
const ua = new UAParser();
const browserName = ua.getBrowser().name || "unknown browser";

Loading…
Cancel
Save