Skip to content

Instantly share code, notes, and snippets.

@zeusdeux
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeusdeux/4e13f4de2d3ffe6ca455 to your computer and use it in GitHub Desktop.
Save zeusdeux/4e13f4de2d3ffe6ca455 to your computer and use it in GitHub Desktop.
Naive URL extraction (only english supported)
1) Starts with http, https? Cool. Take the whole string (assuming it's good after http|https). Stop
2) Contains http, https? Cool. Splice string from index of 'http' ('h' to be more precise) to end of string. Stop.
3) Split on '.'. foldr over the array by trying to split ever element over anything that isnt an alphabet or number. Ignore 1st element of every subsplit if the subsplit returns an array of length greater than 1. After this pass, join whole array using '.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment