Last active
April 23, 2023 11:54
-
-
Save dnnsmnstrr/cab9bbeca50da62f2ac7580ed61f7c0f to your computer and use it in GitHub Desktop.
PastePal transform Spotify URL to URI
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
function transform(clip) { | |
const pathRegex = /^[a-z]+:\/\/[^:\/]+(:[0-9]+)?\/(.*?)(\/[0-9]+)?(\?.*)?$/ | |
const uriPath = clip.text.replace(pathRegex, '$2'); | |
const spotifyUri = "spotify:" + uriPath.replaceAll('/', ':') | |
return spotifyUri; | |
} |
Codelime formatter:
function format(text) {
const pathRegex = /^[a-z]+:\/\/[^:\/]+(:[0-9]+)?\/(.*?)(\/[0-9]+)?(\?.*)?$/
const uriPath = text.replace(pathRegex, '$2');
const spotifyUri = "spotify:" + uriPath.replaceAll('/', ':')
return spotifyUri;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ported to BTT: