gilbarbara/react-inlinesvg

Error: Uncaught [TypeError: src.match is not a function]

Boscop opened this issue · 2 comments

Thanks for this great package! It works well, but I'm getting the following error when running yarn test:

  console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
    Error: Uncaught [TypeError: src.match is not a function]
        at reportException (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:62:24)
        at innerInvokeEventListeners (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:332:9)
        at invokeEventListeners (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:267:3)
        at HTMLUnknownElementImpl._dispatch (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:214:9)
        at HTMLUnknownElementImpl.dispatchEvent (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
        at HTMLUnknownElement.dispatchEvent (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:144:23)
        at Object.invokeGuardedCallbackDev (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/react-dom/cjs/react-dom.development.js:199:16)
        at invokeGuardedCallback (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/react-dom/cjs/react-dom.development.js:256:31)
        at commitRoot (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/react-dom/cjs/react-dom.development.js:18948:7)
        at /opt/atlassian/pipelines/agent/build/impero_web/node_modules/react-dom/cjs/react-dom.development.js:20418:5 TypeError: src.match is not a function
        at InlineSVG.<anonymous> (/opt/atlassian/pipelines/agent/build/impero_web/node_modules/react-inlinesvg/src/index.tsx:229:31)
...

Any idea why? :)

It's in this line:

const dataURI = src.match(/data:image\/svg[^,]*?(;base64)?,(.*)/);

This fixed it:
#140 (comment)

Guria commented

I am getting the same but in runtime after react-scripts start. Started to happen after upgading to reac-scripts@4.0.0