mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-02-02 11:48:25 +00:00
--counter: accept colon character; useful for time-tracking apps with hour:min in title (PR #1378)
Modify regexp to track hour counters such as `(1:23)`. This is supported by macOS' dock and displays in the red badge: https://user-images.githubusercontent.com/73974/162786478-609a90e1-5efb-44ba-9aa5-7a3038f0689b.png
This commit is contained in:
parent
567fede701
commit
6a949ca481
@ -233,6 +233,7 @@ test.each(testNonLoginPages)(
|
||||
|
||||
const smallCounterTitle = 'Inbox (11) - nobody@example.com - Gmail';
|
||||
const largeCounterTitle = 'Inbox (8,756) - nobody@example.com - Gmail';
|
||||
const hourCounterTitle = 'Today (1:23) - nobody@example.com - TimeTracker';
|
||||
const noCounterTitle = 'Inbox - nobody@example.com - Gmail';
|
||||
|
||||
test('getCounterValue should return undefined for titles without counter numbers', () => {
|
||||
@ -247,6 +248,10 @@ test('getCounterValue should return a string for large counter numbers in the ti
|
||||
expect(getCounterValue(largeCounterTitle)).toEqual('8,756');
|
||||
});
|
||||
|
||||
test('getCounterValue should return a string for hour counter numbers in the title', () => {
|
||||
expect(getCounterValue(hourCounterTitle)).toEqual('1:23');
|
||||
});
|
||||
|
||||
describe('removeUserAgentSpecifics', () => {
|
||||
const userAgentFallback =
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) app-nativefier-804458/1.0.0 Chrome/89.0.4389.128 Electron/12.0.7 Safari/537.36';
|
||||
|
@ -56,7 +56,7 @@ export function getAppIcon(): string | undefined {
|
||||
}
|
||||
|
||||
export function getCounterValue(title: string): string | undefined {
|
||||
const itemCountRegex = /[([{]([\d.,]*)\+?[}\])]/;
|
||||
const itemCountRegex = /[([{]([\d.,:]*)\+?[}\])]/;
|
||||
const match = itemCountRegex.exec(title);
|
||||
return match ? match[1] : undefined;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user