Skip to content

Instantly share code, notes, and snippets.

@jlhernando
Created April 6, 2022 10:21
Show Gist options
  • Save jlhernando/bbadf8fb606e2bc13d8ee6512cd4d0a2 to your computer and use it in GitHub Desktop.
Save jlhernando/bbadf8fb606e2bc13d8ee6512cd4d0a2 to your computer and use it in GitHub Desktop.
Decode URLs in Google Sheets creating a custom fucntion in Apps Script
/* Both these funcitons will work fine */
// As a function declaration
function DECODE(url) {
return decodeURI(url)
}
// Or as an arrow function
const DECODEURL = (url) => decodeURI(url)
@campiotto
Copy link

This worked best for me thanks @jlhernando

/* Both these funcitons will work fine */

// As a function declaration
function DECODE(url) {
return decodeURIComponent(url)
}

// Or as an arrow function
const DECODEURL = (url) => decodeURIComponent(url)

@gaiking-uk
Copy link

Just to make the above clear, the function needs to use decodeURIComponent (not decodeURI), so the code should be...

// As a function declaration
function DECODE(url) {
    return decodeURIComponent(url)
}

// Or as an arrow function
const DECODEURL = (url) => decodeURIComponent(url)

Thanks @jlhernando for sharing this originally, and @campiotto for your correction 👍🏼

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