Skip to content

Instantly share code, notes, and snippets.

@davidsharp
Created June 24, 2022 09:08
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 davidsharp/51173d39cd9f6f9929f411c07f0317f3 to your computer and use it in GitHub Desktop.
Save davidsharp/51173d39cd9f6f9929f411c07f0317f3 to your computer and use it in GitHub Desktop.
Ever so slightly shorter version of the Autolink component found in 30 Seconds of Knowledge
@davidsharp
Copy link
Author

davidsharp commented Jun 24, 2022

The behaviour's less clear, but due to the way split works, the URLs will always be the even entries (hence isUrl = i%2)

@davidsharp
Copy link
Author

This naturally also saves a regex running over each item in the array, for which I'm sure there are mostly negligible gains

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment