data-url.js 296 B

1234567891011121314151617
  1. "use strict"
  2. const dataURLRegexp = /^data:text\/css;base64,/i
  3. function isValid(url) {
  4. return dataURLRegexp.test(url)
  5. }
  6. function contents(url) {
  7. // "data:text/css;base64,".length === 21
  8. return Buffer.from(url.slice(21), "base64").toString()
  9. }
  10. module.exports = {
  11. isValid,
  12. contents,
  13. }