Last active
October 12, 2016 01:31
-
-
Save MatthewDaniels/f0c969ce9107e6da4ba2cfa209b8c03b to your computer and use it in GitHub Desktop.
Google App Script to reverse a url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reverses the input url. | |
* | |
* EG: if the url is www.google.com, the result will be com.google.www - this is useful for sorting a sheet | |
* | |
* @param {string} input The url to reverse. | |
* @return The url reversed. | |
* @customfunction | |
*/ | |
function REVERSEURL(string) { | |
if (typeof string != 'string') { | |
return null; | |
} | |
return string.split('.').reverse().join('.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment