All files / src/profiles/services github.ts

93.75% Statements 15/16
75% Branches 3/4
75% Functions 3/4
93.33% Lines 14/15

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  1x         4x 4x               4x 4x   4x   4x 8x 8x 2x 2x     2x       2x       1x  
 
import { Service, CheerioModuleType } from './service'
import { AccountProofInfo } from '../profileProofs'
 
class Github extends Service {
  getBaseUrls() {
    const baseUrls = ['https://gist.github.com/', 'http://gist.github.com', 'gist.github.com']
    return baseUrls
  }
 
  normalizeUrl(_proof: AccountProofInfo) {
    return ''
  }
 
  getProofUrl(proof: AccountProofInfo) {
    const baseUrls = this.getBaseUrls()
    let proofUrl = proof.proof_url.toLowerCase()
 
    proofUrl = super.prefixScheme(proofUrl)
 
    for (let i = 0; i < baseUrls.length; i++) {
      const requiredPrefix = `${baseUrls[i]}${proof.identifier}`.toLowerCase()
      if (proofUrl.startsWith(requiredPrefix)) {
        const raw = proofUrl.endsWith('/') ? 'raw' : '/raw'
        return `${proofUrl}${raw}`
      }
    }
    throw new Error(`Proof url ${proof.proof_url} is not valid for service ${proof.service}`)
  }
 
  getProofStatement(searchText: string, _cheerio: CheerioModuleType) {
    return searchText
  }
}
 
export { Github }