Skip to content

Instantly share code, notes, and snippets.

@steffensbola
Created September 18, 2024 18:44
Show Gist options
  • Select an option

  • Save steffensbola/9a07fc9eeb8874354b1fde2b74ab8a41 to your computer and use it in GitHub Desktop.

Select an option

Save steffensbola/9a07fc9eeb8874354b1fde2b74ab8a41 to your computer and use it in GitHub Desktop.
Extracts the Launch Darkly context from GET URL
function extractLDPayload(url) {
// Extract the Base64-encoded payload from the URL
const encodedPayload = url.split('/').pop();
// Decode the Base64-encoded payload
const decodedPayload = atob(encodedPayload);
// Parse the decoded payload as JSON
const payload = JSON.parse(decodedPayload);
return payload;
}
// Example usage:
//const url = 'https://app.launchdarkly.com/sdk/evalx/5f4d37ba7c8f3709248ae18a/users/....';
//extractLDPayload(url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment