Skip to content

Commit df4e36b

Browse files
committed
fix: add viewport meta tag to cloaked links for improved mobile support #301
1 parent cb572f6 commit df4e36b

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

server/utils/template.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function generateCloakingHtml(link: Link, targetUrl: string, baseUrl: str
3434
<html>
3535
<head>
3636
<meta charset="utf-8">
37+
<meta name="viewport" content="width=device-width,initial-scale=1">
3738
<title>${escape(title)}</title>
3839
${tags}
3940
</head>

tests/redirect.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,26 @@ describe('/', () => {
9999
expect(html).toContain(cnUrl)
100100
})
101101

102+
it('adds viewport meta to cloaked links for mobile browsers (fixes #301)', async () => {
103+
const slug = `cloaking-viewport-${crypto.randomUUID()}`
104+
const targetUrl = 'https://example.com/mobile-target'
105+
106+
const createResponse = await postJson('/api/link/create', {
107+
url: targetUrl,
108+
slug,
109+
cloaking: true,
110+
})
111+
expect(createResponse.status).toBe(201)
112+
createdSlugs.push(slug)
113+
114+
const response = await fetch(`/${slug}`, { redirect: 'manual' })
115+
const html = await response.text()
116+
117+
expect(response.status).toBe(200)
118+
expect(html).toContain('<meta name="viewport" content="width=device-width,initial-scale=1">')
119+
expect(html).toContain(`<iframe src="${targetUrl}"`)
120+
})
121+
102122
it('prefers device redirect over geo redirect', async () => {
103123
const slug = `device-over-geo-${crypto.randomUUID()}`
104124
const apple = 'https://apps.apple.com/app/sink-test-priority'

0 commit comments

Comments
 (0)