Skip to content

Instantly share code, notes, and snippets.

View mitchbudreski's full-sized avatar

Mitch Budreski mitchbudreski

  • Vancouver, B.C.
View GitHub Profile
@mitchbudreski
mitchbudreski / gist:6444d0f6e5b5187ba4fb7a905b69ffa8
Created September 21, 2021 20:36
In progress | domain specific authentication for video embedding sites
export function parseYoutubeUrl(url) {
// - Supported YouTube URL formats:
// - http://www.youtube.com/watch?v=My2FRPA3Gf8
// - http://youtu.be/My2FRPA3Gf8
// - https://youtube.googleapis.com/v/My2FRPA3Gf8
// - Supported Vimeo URL formats:
// - http://vimeo.com/25451551
// - http://player.vimeo.com/video/25451551
// - Also supports relative URLs:
// - //player.vimeo.com/video/25451551
@mitchbudreski
mitchbudreski / gist:0f87b51d8ace2aa2d08e814c1cbd3635
Created September 20, 2021 16:22
Urlify - Pretty URL slugs without EncodeURI functions
//the function
export function urlify(text) {
return text
.toString()
.toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
@mitchbudreski
mitchbudreski / gist:cf86379e33f8ffe3072f79e617e2754a
Created September 20, 2021 16:08
Keyify - Turning any string to make a dynamic object key
export function keyIfy(text) {
return text
.toString()
.toLowerCase()
.replace(/\s+/g, '_') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '_') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}