@@ -7,6 +7,10 @@ import 'package:html/parser.dart';
77import 'package:shared_preferences/shared_preferences.dart' ;
88
99class LearnFileService {
10+ String getFullFileName (ChallengeFile file) {
11+ return '${file .name }.${file .ext .value }' ;
12+ }
13+
1014 // This function returns a specific file content from the cache.
1115 // If testing is enabled on the function it will return
1216 // the first file with the given file name.
@@ -20,11 +24,12 @@ class LearnFileService {
2024
2125 if (testing) {
2226 cache = challenge.files
23- .firstWhere ((element) => element.name == file.name)
27+ .firstWhere (
28+ (element) => getFullFileName (element) == getFullFileName (file))
2429 .contents;
2530 } else {
2631 SharedPreferences prefs = await SharedPreferences .getInstance ();
27- cache = prefs.getString ('${challenge .id }.${file . name }' );
32+ cache = prefs.getString ('${challenge .id }.${getFullFileName ( file ) }' );
2833 }
2934
3035 return cache ?? file.contents;
@@ -40,7 +45,7 @@ class LearnFileService {
4045 await prefs.setString ('${challenge .id }.$currentSelectedFile ' , value);
4146 }
4247
43- // This funciton returns the first file content with the given extension from the
48+ // This function returns the first file content with the given extension from the
4449 // cache. If testing is enabled it will return the file directly from the challenge.
4550 // If a CSS extension is put as a parameter it will return the first HTML file instead.
4651
@@ -67,7 +72,7 @@ class LearnFileService {
6772 SharedPreferences prefs = await SharedPreferences .getInstance ();
6873
6974 fileContent = prefs.getString (
70- '${challenge .id }.${firstChallenge [0 ]. name }' ,
75+ '${challenge .id }.${getFullFileName ( firstChallenge [0 ]) }' ,
7176 ) ??
7277 firstChallenge[0 ].contents;
7378 }
@@ -98,7 +103,7 @@ class LearnFileService {
98103
99104 if (fileWithEditableRegion.isNotEmpty) {
100105 cache = prefs.getString (
101- '${challenge .id }.${fileWithEditableRegion [0 ]. name }' ,
106+ '${challenge .id }.${getFullFileName ( fileWithEditableRegion [0 ]) }' ,
102107 ) ??
103108 '' ;
104109
@@ -204,7 +209,7 @@ class LearnFileService {
204209 testing: testing,
205210 );
206211
207- if (! await cssFileIsLinked (content, '${ file . name }.${ file . ext . name }' )) {
212+ if (! await cssFileIsLinked (content, getFullFileName ( file) )) {
208213 continue ;
209214 }
210215
@@ -246,7 +251,7 @@ class LearnFileService {
246251
247252 if (jsFiles.isNotEmpty) {
248253 for (ChallengeFile file in jsFiles) {
249- String filename = '${ file . name }.${ file . ext . name }' ;
254+ String filename = getFullFileName ( file) ;
250255 String ? fileContents = await getExactFileFromCache (
251256 challenge,
252257 file,
0 commit comments