-2

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.

user3618585
  • 39
  • 1
  • 1
  • 9

2 Answers2

0

You could try this pattern

 / *= *ABCDEFGZ-/g
Hian
  • 1,462
  • 7
  • 6
0

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.

samthecodingman
  • 23,122
  • 4
  • 30
  • 54
  • Fantastics!!! I used the second entry and it s working great!! Thank you. Question - Do you belive it's a good practice to whitelist URLs from affiliates? Those short links are posted on social media. – user3618585 Jan 14 '20 at 18:19
  • Personally I'd be whitelisting the top-level domains along with the affiliate ID. e.g. `^https://some.example.com/.*=Xqv79DCBYJo&.*$` – samthecodingman Jan 14 '20 at 18:37
  • I just followed your recommendation and it s working great. Thank you again! – user3618585 Jan 14 '20 at 19:38
  • I actually haven't yet used dynamic links so I wouldn't know. The best practice is to always tighten up your security rather than leave holes that can be exploited. If you can tighten up the security without sacrificing the functionality you desire, you should do so. – samthecodingman Jan 15 '20 at 20:59
  • I appreciate your input. Thank you very much – user3618585 Jan 17 '20 at 03:55