Skip to content

Commit efb7216

Browse files
committed
use casecmp to check sb3 extension
1 parent 5eebc0c commit efb7216

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

app/models/filesystem_project.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def self.categorize_files(files, dir)
5656
def self.component(file, dir)
5757
name = File.basename(file, '.*')
5858
extension = File.extname(file).delete('.')
59-
return { name:, extension:, file_path: dir.join(File.basename(file)).to_s } if extension == 'sb3'
59+
return { name:, extension:, file_path: dir.join(File.basename(file)).to_s } if extension.casecmp?('sb3')
6060

6161
code = File.read(dir.join(File.basename(file)).to_s)
6262
default = (File.basename(file) == 'main.py')

lib/project_importer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def create_components
5555
# .sb3 files are only ever imported as a ScratchComponent (see
5656
# create_scratch_component); they carry an :io/:file_path key that is not a
5757
# Component attribute, so skip them here to avoid building invalid rows.
58-
next if component[:extension] == 'sb3'
58+
next if component[:extension]&.casecmp?('sb3')
5959

6060
project_component = Component.new(**component)
6161
project.components << project_component
@@ -66,7 +66,7 @@ def create_scratch_component
6666
return unless project.scratch_project?
6767

6868
component = components[0]
69-
return unless component&.fetch(:extension, nil) == 'sb3'
69+
return unless component&.fetch(:extension, nil)&.casecmp?('sb3')
7070

7171
parsed_content = Sb3Parser.new(component: component).parse.fetch(:scratch_component).fetch(:content)
7272
raise ImportError, 'Scratch project content could not be parsed' if parsed_content.blank?
@@ -78,7 +78,7 @@ def create_scratch_assets
7878
return unless project.scratch_project?
7979

8080
component = components[0]
81-
return unless component&.fetch(:extension, nil) == 'sb3'
81+
return unless component&.fetch(:extension, nil)&.casecmp?('sb3')
8282

8383
parsed_assets = Sb3Parser.new(component: component).parse.fetch(:assets)
8484
ScratchSb3AssetImporter.import_all(parsed_assets)

0 commit comments

Comments
 (0)