about summary refs log tree commit diff
path: root/bskylink/src/html/linkWarningContents.ts
blob: 31449c3c86148358ec9870a188cb54a9ddb98f9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import escapeHTML from 'escape-html'
import {type Request} from 'express'

export function linkWarningContents(
  req: Request,
  opts: {
    type: 'warn' | 'block'
    link: string
  },
): string {
  const continueButton =
    opts.type === 'warn'
      ? `<a class="button secondary" href="${escapeHTML(opts.link)}">${req.__('Continue Anyway')}</a>`
      : ''

  return `
    <div class="warning-icon">⚠️</div>
    <h1>
      ${
        opts.type === 'warn'
          ? req.__('Potentially Dangerous Link')
          : req.__('Blocked Link')
      }
    </h1>
    <p class="warning-text">
      ${
        opts.type === 'warn'
          ? req.__(
              'This link may be malicious. You should proceed at your own risk.',
            )
          : req.__(
              'This link has been identified as malicious and has blocked for your safety.',
            )
      }
    </p>
    <div class="blocked-site">
      <p class="site-url">${escapeHTML(opts.link)}</p>
    </div>
    <div class="button-group">
      ${continueButton}
      <a class="button primary" href="https://bsky.app">${req.__('Return to Bluesky')}</a>
    </div>
  `
}