refactor(ui): simplify formatDeviceName with regex in devices template
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -329,11 +329,9 @@ function devicesPage() {
|
|||||||
/** Extract the device name from the full token name (e.g. "Mobile App – iPhone 15 Pro" → "iPhone 15 Pro"). */
|
/** Extract the device name from the full token name (e.g. "Mobile App – iPhone 15 Pro" → "iPhone 15 Pro"). */
|
||||||
formatDeviceName(name) {
|
formatDeviceName(name) {
|
||||||
if (!name) return 'Unknown Device';
|
if (!name) return 'Unknown Device';
|
||||||
const sep = name.indexOf('–');
|
// Match either em dash (–) or hyphen (-) separators used by the mobile flows.
|
||||||
if (sep > -1) return name.substring(sep + 1).trim();
|
const match = name.match(/[–\-]\s*(.+)$/);
|
||||||
const dash = name.indexOf('-');
|
return match ? match[1].trim() : name;
|
||||||
if (dash > -1) return name.substring(dash + 1).trim();
|
|
||||||
return name;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
formatDate(d) {
|
formatDate(d) {
|
||||||
|
|||||||
Reference in New Issue
Block a user