Wednesday, May 11, 2022

musicians type the darndest things

One thing I've learned from doing websites for Porchfests is that musicians are going to push any input assumption you might think of. Ask them to put choose a genre for themselves with a small input box, and you might get something like "indie surf dad-rock with nu-wave techno emo edge". Give them a small textfield to describe themselves and you might get 3 paragraphs of their press release.

In the case of Somerville Porchfest, it was decided it could do more to encourage people to support the musicians, so a tipjar field to solicit donations was added. Whoever setup the form did this prompt:

Place a link to fundraising or music download site.
 
So a lot of musicians dutifully entered wellformed links beginning with "http" - and honestly I don't blame the ones who just put in a url without the http, that would be a pretty geeky ask, but the pile of non-http-starting "links" looked like this: (blatantly non-link/site things bolded)

thesestainsarewhoiam.bandcamp.com
instagram.com/bigravband
plumesplumesplumes.bandcamp.com
venmo@Todd-Bleckley
www.venmo.com/Kenneth-Lafler
missbones.bandcamp.com
jefczekaj.bandcamp.com
Venmo: @Melissa-Nilles
connorstorms.bandcamp.com
by dancing!
Just go to Ball Square Fine Wines and pick us up a six pack if you must, we're not picky
Venmo @JennyJuggler
Venmo @Andre-LaPan
Don't encourage us
www.venmo.com/Jeff-Jam-1
Doublelibra.Bandcamp.com
ensmb.bandcamp.com
TBA
@cyclopolitan on Venmo
birdlanguagema.bandcamp.com

So I needed a heuristic to translate these into URLs (like by slapping https:// on the front) if they seemed like a URL, or to a venmo link if they looked like a venmo thing (but we had a few patterns for that, including Venmo URLs and then cyclopolitan who put the phrase "on Venmo" after). For everything else, I made up a system to alert() the text they entered.

Long story short here's what I came up with:
  function mungeSupportLink(info){
    if(! info) return;
    if(info.toLowerCase().includes('venmo') && info.includes('@')) {
        const regExp = /\@(\S*)(.*?)$/;
        const matches = regExp.exec(info);
        if(matches) {
            const username = matches[1];
            return `https://account.venmo.com/u/${username}`;
        } else {
            console.log(matches,'for',info)   
        }
    }
    if(! info.includes(' ') && info.includes('.')) return `https://${info}`;
    return info;
}

The non-URL venmo links all had a "@" in them, so I used a regex to isolate the username (assuming non-whitespace usernames, especially important for "@cyclopolitan on Venmo").

For the non venmo stuff, I figured the URLs didn't have spaces (I already trim()d them) but WOULD have at least a "." subdomain separator, and if not we just return it as is for inclusion as an alert...

No comments:

Post a Comment