Skip to content

Instantly share code, notes, and snippets.

View guag's full-sized avatar

Gary Guagliardo Jr guag

View GitHub Profile
@guag
guag / detectDataURL.js
Last active August 29, 2015 14:21 — forked from bgrins/detectDataURL.js
Changed function to use test() instead of match()
// Detecting data URLs
// data URI - MDN https://developer.mozilla.org/en-US/docs/data_URIs
// The "data" URL scheme: http://tools.ietf.org/html/rfc2397
// Valid URL Characters: http://tools.ietf.org/html/rfc2396#section2
function isDataURL(s) {
return isDataURL.regex.test(s);
}
isDataURL.regex = /^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i;