feat: installable PWA with mobile share-target capture
- Corrected manifest (Jobbjakt branding, matching green theme, maskable icons, description/categories/scope/id). - share_target (GET) maps a shared url/link into the same /?add= capture flow the bookmarklet uses, so mobile 'Share -> Jobbjakt' pre-fills Add Job. - resolveCaptureUrl helper (tested) extracts the link from add or from a link embedded in shared text; App uses it and strips the params. - Deliberately no offline service worker: the app deploys frequently and an aggressive cache would risk stale builds (documented in README). - 4 unit tests; build compiles. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { resolveCaptureUrl } from './captureUrl';
|
||||
|
||||
describe('resolveCaptureUrl', () => {
|
||||
test('reads the bookmarklet add param', () => {
|
||||
expect(resolveCaptureUrl('?add=https%3A%2F%2Fexample.com%2Fjob')).toBe('https://example.com/job');
|
||||
});
|
||||
|
||||
test('extracts a url embedded in shared text', () => {
|
||||
expect(resolveCaptureUrl('?addtext=' + encodeURIComponent('Cool role here https://example.com/job/42 apply now')))
|
||||
.toBe('https://example.com/job/42');
|
||||
});
|
||||
|
||||
test('prefers add over addtext', () => {
|
||||
expect(resolveCaptureUrl('?add=https%3A%2F%2Fa.com&addtext=' + encodeURIComponent('https://b.com')))
|
||||
.toBe('https://a.com');
|
||||
});
|
||||
|
||||
test('returns null when there is no url', () => {
|
||||
expect(resolveCaptureUrl('')).toBeNull();
|
||||
expect(resolveCaptureUrl('?addtext=' + encodeURIComponent('just some text, no link'))).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user