@@ -13,16 +13,19 @@ import (
1313func TestPlaygroundAssetGraphComplete (t * testing.T ) {
1414 imports := regexp .MustCompile (`(?:from\s*|import\s*)["']([^"']+)["']` )
1515 styles := regexp .MustCompile (`@import\s+(?:url\()?\s*["']([^"']+)["']` )
16+ htmlAssets := regexp .MustCompile (`(?:href|src)\s*=\s*["']([^"']+)["']` )
1617 err := fs .WalkDir (playgroundUI , "playground" , func (name string , entry fs.DirEntry , walkErr error ) error {
1718 require .NoError (t , walkErr )
18- if entry .IsDir () || (! strings .HasSuffix (name , ".js" ) && ! strings .HasSuffix (name , ".css" )) {
19+ if entry .IsDir () || (! strings .HasSuffix (name , ".js" ) && ! strings .HasSuffix (name , ".css" ) && ! strings . HasSuffix ( name , ".html" ) ) {
1920 return nil
2021 }
2122 contents , err := playgroundUI .ReadFile (name )
2223 require .NoError (t , err )
2324 patterns := []* regexp.Regexp {imports }
2425 if strings .HasSuffix (name , ".css" ) {
2526 patterns = []* regexp.Regexp {styles }
27+ } else if strings .HasSuffix (name , ".html" ) {
28+ patterns = []* regexp.Regexp {htmlAssets }
2629 }
2730 for _ , pattern := range patterns {
2831 for _ , match := range pattern .FindAllSubmatch (contents , - 1 ) {
@@ -31,8 +34,8 @@ func TestPlaygroundAssetGraphComplete(t *testing.T) {
3134 continue
3235 }
3336 target := path .Clean (path .Join (path .Dir (name ), reference ))
34- if strings .HasPrefix (reference , "/" ) {
35- target = path .Join ("playground" , reference )
37+ if rootReference , ok := strings .CutPrefix (reference , "/" ); ok {
38+ target = path .Join ("playground" , rootReference )
3639 }
3740 _ , err := fs .Stat (playgroundUI , target )
3841 require .NoError (t , err , "%s references missing asset %s" , name , reference )
0 commit comments