Created
September 18, 2024 18:44
-
-
Save steffensbola/9a07fc9eeb8874354b1fde2b74ab8a41 to your computer and use it in GitHub Desktop.
Extracts the Launch Darkly context from GET 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
| 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