Skip to content

Instantly share code, notes, and snippets.

@brandongalbraith
Forked from dnnsmnstrr/spotifyUri.js
Created January 2, 2026 19:12
Show Gist options
  • Select an option

  • Save brandongalbraith/4cc43619262466cb2296e79bf2bea544 to your computer and use it in GitHub Desktop.

Select an option

Save brandongalbraith/4cc43619262466cb2296e79bf2bea544 to your computer and use it in GitHub Desktop.

Revisions

  1. @dnnsmnstrr dnnsmnstrr revised this gist Feb 19, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions spotifyUri.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    function transform(clip) {
    const pathRegex = /^[a-z]+:\/\/[^:\/]+(:[0-9]+)?\/(.*?)(\/[0-9]+)?(\?.*)?$/
    const uriPath = clip.text.replace(pathRegex, '$2');
    const spotifyUri = "spotify:" + uriPath.replaceAll('/', ':')
    const uriPath = clip.text.replace(pathRegex, '$2');
    const spotifyUri = "spotify:" + uriPath.replaceAll('/', ':')
    return spotifyUri;
    }
  2. @dnnsmnstrr dnnsmnstrr created this gist Feb 19, 2023.
    6 changes: 6 additions & 0 deletions spotifyUri.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    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;
    }