'use strict'

import { Service } from "./service"

class Facebook extends Service {
  static getBaseUrls() {
    const baseUrls = ["https://facebook.com/", "https://www.facebook.com"]
    return baseUrls
  }

  static getProofUrl(proof) {
    let proofUrl = super.getProofUrl(proof)
    return this.normalizeFacebookUrl(proofUrl)
  }

  /* Facebook url proofs should start with www. */
  static normalizeFacebookUrl(proofUrl) {
    if(proofUrl.startsWith("https://facebook.com")) {
      let tokens = proofUrl.split("https://facebook.com")
      proofUrl = "https://www.facebook.com" + tokens[1]
    }
    let tokens = proofUrl.split("https://www.facebook.com/")[1].split("/posts/")
    let postId = tokens[1]
    proofUrl = "https://www.facebook.com/" + username + "/posts/" + postId
    return proofUrl
  }
}

export { Facebook }

@@ -236,52 +236,8 @@
 ) %7B%0A
-    let proofUrl = super.getProofUrl(proof)%0A
     
@@ -274,19 +274,16 @@
 rl(proof
-Url
 )%0A  %7D%0A%0A 
@@ -371,14 +371,55 @@
 roof
-Url
 ) %7B
+%0A    let proofUrl = super.getProofUrl(proof)
 %0A   
@@ -746,16 +746,24 @@
 %22 + 
-username
+proof.identifier
  + %22

update normalizeFacebookUrl to take proof object #202