Skip to content

Instantly share code, notes, and snippets.

@stefanosaittamrf
Last active May 4, 2016 10:28
Show Gist options
  • Save stefanosaittamrf/f5e2b671465fc11795dfc1a369f94a1a to your computer and use it in GitHub Desktop.
Save stefanosaittamrf/f5e2b671465fc11795dfc1a369f94a1a to your computer and use it in GitHub Desktop.
//I write this down in order to remove hardcoded link into a whiteCollar/main.js
const noSubDomainRegex = /^http(s)?:\/\/(?:www\.)[a-z1-9]+.[a-z]\/?[a-zA-Z0-9_?=&\/\-.]+$/; //K cost, no performance issue
!noSubDomainRegex.test(item.uri) ? return null : return item; // this will cost N where n is the length of the string
// the cost of this is O(K*n) => O(n)*
//* for a big N. Can be considered as constant for a small N.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment