Skip to content

Instantly share code, notes, and snippets.

@aashreys
Created November 29, 2022 19:14
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 aashreys/fb3e623992f821d7d3165badc1c059e4 to your computer and use it in GitHub Desktop.
Save aashreys/fb3e623992f821d7d3165badc1c059e4 to your computer and use it in GitHub Desktop.
Get Figma Node ID from URL
export function getNodeIdFromUrl(url: string): string | null {
url = url.toLowerCase()
let startIndex: number = url.indexOf('node-id=') + 8
let endIndex: number = url.indexOf('&', startIndex)
if (startIndex) {
if (endIndex > 0) {
return url.substring(startIndex, endIndex).replace('%3a', ':')
} else {
return url.substring(startIndex).replace('%3a', ':')
}
} else {
return null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment