single-spa / single-spa-playground

A website that helps you set up single-spa
http://single-spa-playground.org
MIT License
39 stars 10 forks source link

Fix/systemjsmodule appdependencies regex #26

Closed filoxo closed 4 years ago

filoxo commented 4 years ago

I found that the regex for parsing the shared deps array was incorrect if it was empty (eg. System.register([],(function(e){}))) (source). This PR changes the regex so that it capture zero or many characters, as well as handles if the captured string is unable to be JSON.parsed.

To validate this fix:

  1. Go to https://regex101.com/
  2. Provide ^System\.register\((\[.*?\])
  3. test with an System.register string with an empty array such this one
  4. test with a System.register string that has values (just edit the above)

Both should return the array of the System.register call.