# All files / src/profiles/services linkedIn.ts

79.17% Statements 19/24
100% Branches 0/0
66.67% Functions 4/6
79.17% Lines 19/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    1x
    1x

    1x

    1x

    1x
    1x

    1x

    1x

    1x
    1x

    1x

    1x

    1x

    2x
    2x
    2x

    2x

    2x

    1x

    import cheerio from 'cheerio'
    import { Service } from './service'

    class LinkedIn extends Service {
      static getBaseUrls() {
        const baseUrls = [
          'https://www.linkedin.com/feed/update/',
          'http://www.linkedin.com/feed/update/',
          'www.linkedin.com/feed/update/'
        ]
        return baseUrls
      }

      static getProofUrl(proof: any) {
        const baseUrls = this.getBaseUrls()

        let proofUrl = proof.proof_url.toLowerCase()
        proofUrl = super.prefixScheme(proofUrl)

        for (let i = 0; i < baseUrls.length; i++) {
          if (proofUrl.startsWith(`${baseUrls[i]}`)) {
            return proofUrl
          }
        }
        throw new Error(`Proof url ${proof.proof_url} is not valid for service ${proof.service}`)
      }

      static normalizeUrl(proof: any) {
        return ''
      }

      static shouldValidateIdentityInBody() {
        return true
      }

      static getProofIdentity(searchText: string) {
        const $ = cheerio.load(searchText)
        const profileLink = $('body > main header a')

        if (profileLink !== undefined) {
          if (profileLink.attr('href') === undefined) {
            return ''
          }
          const url = profileLink.attr('href')

          // Parse URL for identifier
          const identifier = url.split('?').shift().split('/').pop()

          return identifier
        } else {
          return ''
        }
      }

      static getProofStatement(searchText: string) {
        const $ = cheerio.load(searchText)
        const postContent = $('head > meta[property="og:title"]')
        let statement = ''

        if (postContent !== undefined) {
          statement = postContent.attr('content')
        }

        return statement
      }
    }

    export { LinkedIn }