(there’s a quasi Beatles reference in that title)

What would you do if my code spit an error?
Would you stand up and tweet out to me?
Send me an link and I’ll try to replicate
I will try to fix it quickly.

This is how stuff works. Someone I don’t know tweets about an error message in one of my code projects.

I’ve been surprised there’s not been more glitches with the Storify Embeddable Link Extractor, which is aimed at getting content out of a storify page’s HTML (which are now completely dead and gone and buried) that can be embedded into WordPress.

I thought maybe Christina was hitting an issue where her storifies were already gone, but she had extracted them earlier. Smart.

But what error? That is helpful in getting the answer.

That helps a little, it means that my code had borked somewhere on parsing the info. Christina sent me by email the HTML files she was getting errors on, and I confirmed it.

So it’s my fault.

I did have a hunch. The regex pattern matching my site uses to identify content is dependent on lines ending in a carriage return. And I saw one of her text block added to storify had extra line returns. Removing them from her source made the error vanish.

My guess was I needed to remove all line returns from the chunk of text I was using, which is what is pasted into the textarea. My previous code had:

$( "form" ).submit(function( event ) {
	// our raw input. yum.
	var raw = $('#raw').val();

A little bit of googling and some Stack Exchange examples on regex got me to modify that code:

$( "form" ).submit(function( event ) {
	// our raw input. yum. yank the newlines.
	var raw = $('#raw').val().replace(/(\r\n\t|\n|\r\t)/gm,"");

It worked locally with the HTML Christina had sent, so it was push the changes to github, and let her try again.

and good news!

Thanks Christina, someone I have never communicated with, for helping me make my code a wee bit better.

It’s never quite ever done.


Featured Image:

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Leave a Reply

Your email address will not be published. Required fields are marked *