Search code examples
regexfirebaseaffiliate

How to Whitelist URLs with specific keywords?


I am using Firebase to shorten link from affiliates.

I need to whitelist URLs with specific keyword. That keyword would be my account ID.

For example, all deep links will contain the keyword "ABCDEFGZ".

https://www.macys.com/shop/product/fantasy-flight-games-star-wars-x-wing-miniatures-game-kihraxz-fighter-expansion-pack?ID=10379715&PartnerID=LINKSHARE&cm_mmc=LINKSHARE--47--39-_-MP4739&ranMID=3184&ranEAID=Xqv79DCBYJo&ranSiteID=ABCDEFGZ-zhNFRS_B3yd3S8B_WT1_dQ&LinkshareID=Xqv79DCBYJo-zhNFRS_B3yd3S8B_WT1_dQ&m_sc=aff&PartnerID=LINKSHARE

What would be the Regex URL pattern?

Here is a real link from affiliate:

https://click.linksynergy.com/link?id=Xqv79DCBYJo&offerid=115554.71711&type=2&murl=https%3A%2F%2Fwww.lego.com%2Fen-us%2Fproduct%2Fjays-cyber-dragon-71711

My affiliate ID is Xqv79DCBYJo.

The Regex URL I put is:

/*= *Xqv79DCBYJo&/g

I don't know why it s not working, does spacing between characters has a role?

Please see this image:

Screen shot of dialog box

Okay let s work an example: Deep Link from Affiliate network: https://click.linksynergy.com/link?id=Xqv79DCBYJo&offerid=727010.8053672236323&type=2&murl=https://www.macys.com/shop/product/vogue-eyewear-womens-sunglasses?ID%3D10323875%26PartnerID%3DLINKSHARE%26cm_mmc%3DLINKSHARE--91--67-_-MP9167%22+rel%3D%22nofollow%22

Short Link from Firebase: https://ads.shipperman.us/voguesg

Link directed to marketer: https://www.macys.com/shop/product/vogue-eyewear-womens-sunglasses?ID=10323875&PartnerID=LINKSHARE&cm_mmc=LINKSHARE--91--67-_-MP9167%22+rel=%22nofollow%22&ranMID=3184&ranEAID=Xqv79DCBYJo&ranSiteID=Xqv79DCBYJo-6CcQxckWK7hjSgxbQrnmYQ&LinkshareID=Xqv79DCBYJo-6CcQxckWK7hjSgxbQrnmYQ&m_sc=aff&PartnerID=LINKSHARE

As you see, my customer ID is Xqv79DCBYJo.


Solution

  • Try these as separate entries (at the same time):

    For when your affiliate is the last entry in the URL:

    ^https://.*=Xqv79DCBYJo$
    

    For when your affiliate is the somewhere in the middle of the URL:

    ^https://.*=Xqv79DCBYJo&.*$
    

    These regular expressions use RE2 syntax which is a very basic regex implementation. Many common idioms such as "/g" do not work for these. See the syntax reference for details.