@@ -22,7 +22,7 @@ var _url_normalization_regex := RegExpGroup.compile(
2222 r "^(?<prefix>user:\/\/ |res:\/\/ |\. *?\/ +)(?<course>[^\/ ]+)\/ (?<lesson>[^\/ ]+)\/ ?(?<lesson_file>[^\. ]+\. [^\/ ]+)?\/ ?(?<practice>.*)?" ,
2323)
2424var _slug_normalization_regex := RegExpGroup .compile (
25- r "^(?<course>[^ \/ ]+) \/ (?< lesson>[^\/ ]+)\/ ?(?<practice>.*)?" ,
25+ r "^(?<lesson>[^\/ ]+)\/ ?(?<practice>.*)?" ,
2626)
2727var _lesson_cache := { }
2828
@@ -136,12 +136,12 @@ func navigate_to_welcome_screen() -> void:
136136 welcome_screen_navigation_requested .emit ()
137137
138138
139- func navigate_to_lesson (course_id : String , lesson_slug : String ) -> void :
140- navigate_to ("%s / %s " % [course_id , lesson_slug ])
139+ func navigate_to_lesson (lesson_slug : String ) -> void :
140+ navigate_to ("%s " % [lesson_slug ])
141141
142142
143- func navigate_to_practice (course_id : String , lesson_slug : String , practice_id : String ) -> void :
144- navigate_to ("%s /%s / %s " % [course_id , lesson_slug , practice_id ])
143+ func navigate_to_practice (lesson_slug : String , practice_id : String ) -> void :
144+ navigate_to ("%s /%s " % [lesson_slug , practice_id ])
145145
146146
147147func navigate_to (metadata : String ) -> void :
@@ -155,16 +155,13 @@ func navigate_to(metadata: String) -> void:
155155
156156 var normalized := NormalizedUrl .new (regex_result )
157157
158- var course_index := CourseIndexPaths .get_course_index_instance (normalized .course_path )
159- if not course_index :
160- push_error ("'%s ' is not a valid course" % [normalized .course_path ])
161- return
158+ var course_index := CourseIndexPaths .get_course_index_instance (CourseIndexPaths .DEFAULT_COURSE_INDEX )
162159
163160 # legacy slugs support
164161 var legacy_path := normalized .lesson_path
165162 var lesson_slug := course_index .get_real_slug_from_slug (legacy_path )
166163 if lesson_slug != legacy_path :
167- regex_result = _slug_normalization_regex .search ("%s / %s " % [course_index . get_course_id (), lesson_slug ])
164+ regex_result = _slug_normalization_regex .search ("%s " % [lesson_slug ])
168165 normalized = NormalizedUrl .new (regex_result )
169166
170167 var lesson_path := course_index .get_lesson_path_from_slug (normalized .lesson_path )
@@ -174,7 +171,7 @@ func navigate_to(metadata: String) -> void:
174171 push_error ("`%s ` is not a lesson" % lesson_path )
175172 return
176173
177- var effective_path := "%s / %s " % [course_index . get_course_id (), normalized .lesson_path ]
174+ var effective_path := "%s " % [normalized .lesson_path ]
178175 if normalized .practice_path != "" :
179176 var practice := course_index .get_practice_from_slug ("%s /%s " % [normalized .lesson_path , normalized .practice_path ])
180177 if not practice is BBCodeParser .ParseNode :
@@ -195,12 +192,13 @@ func get_navigation_resource(resource_id: String) -> BBCodeParser.ParseNode:
195192 is_slug = true
196193 normalized_url_groups = _slug_normalization_regex .search (resource_id )
197194 var is_practice := not normalized_url_groups .get_string ("practice" ).is_empty ()
195+
196+ var course_index := CourseIndexPaths .get_course_index_instance (CourseIndexPaths .DEFAULT_COURSE_INDEX )
198197
199198 var bbcode_path := resource_id
200199 if is_practice :
201200 bbcode_path = bbcode_path .left (- (normalized_url_groups .get_end ("practice" )- normalized_url_groups .get_start ("practice" )+ 1 ))
202201 if is_slug :
203- var course_index := CourseIndexPaths .get_course_index_instance (normalized_url_groups .get_string ("course" ))
204202 bbcode_path = course_index .get_lesson_path_from_slug (normalized_url_groups .get_string ("lesson" ).trim_suffix ("/" ))
205203
206204 var lesson_data : BBCodeParser .ParseNode = null
@@ -227,7 +225,6 @@ func get_navigation_resource(resource_id: String) -> BBCodeParser.ParseNode:
227225 _lesson_cache [bbcode_path ] = lesson_data
228226
229227 if is_practice :
230- var course_index := CourseIndexPaths .get_course_index_instance (normalized_url_groups .get_string ("course" ))
231228 var lesson_slug := course_index .get_lesson_slug_from_path (bbcode_path )
232229 return course_index .get_practice_from_slug ("%s /%s " % [lesson_slug , normalized_url_groups .get_string ("practice" )])
233230 return lesson_data
@@ -354,15 +351,13 @@ func _push_javascript_state(url: String) -> void:
354351
355352class NormalizedUrl :
356353 var protocol := ""
357- var course_path := ""
358354 var lesson_path := ""
359355 var practice_path := ""
360356 var lesson_file := ""
361357
362358
363359 func _init (regex_result : RegExMatch ) -> void :
364360 protocol = regex_result .get_string ("prefix" )
365- course_path = regex_result .get_string ("course" )
366361 lesson_path = regex_result .get_string ("lesson" ).trim_suffix ("/" )
367362 practice_path = regex_result .get_string ("practice" )
368363 lesson_file = regex_result .get_string ("lesson_file" )
@@ -371,26 +366,8 @@ class NormalizedUrl:
371366 protocol = "res://"
372367
373368
374- func get_file_path (with_practices : bool = false ) -> String :
375- var file_path := "%s%s /%s " % [protocol , course_path , lesson_path ]
376- if lesson_file != "" :
377- file_path += "/%s " % [lesson_file ]
378- if with_practices and practice_path != "" :
379- file_path += "/%s " % [practice_path ]
380- return file_path
381-
382-
383- func get_web_url () -> String :
384- var url := "%s /%s " % [course_path , lesson_path ]
385- if lesson_file != "" :
386- url += "/%s " % [lesson_file ]
387- if practice_path != "" :
388- url += "/%s " % [practice_path ]
389- return url
390-
391-
392369 func _to_string () -> String :
393- var string := "%s%s /%s " % [protocol , course_path , lesson_path ]
370+ var string := "%s%s /%s " % [protocol , CourseIndexPaths . DEFAULT_COURSE_INDEX , lesson_path ]
394371 if lesson_file != "" :
395372 string += "/%s " % [lesson_file ]
396373 if practice_path != "" :
0 commit comments