FullStory Org Code JS Input Helper
This file contains 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
<script type="text/javascript"> | |
(function() { | |
/* | |
* Helper to extract FullStory Org code from URL when used in a HTML input element | |
*/ | |
const SCHEME_INDICATOR = '://'; | |
const URL_PATH_SEPARATOR = '/'; | |
const FULLSTORY_DOMAIN_INDICATOR = 'app.fullstory.com'; | |
document.querySelector('#fullstory_org_code').addEventListener('input', function(event) { | |
const curInput = event.target; | |
const curValue = curInput.value; | |
if (curValue.includes(SCHEME_INDICATOR) && curValue.includes(FULLSTORY_DOMAIN_INDICATOR)) { | |
const urlParts = curValue.split(URL_PATH_SEPARATOR); | |
curInput.value = urlParts.length > 5 ? urlParts[4] : curValue; | |
} | |
}); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment