Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
fix: fix open image files issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 24, 2022
1 parent e198995 commit fb31740
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Expand Up @@ -39,9 +39,9 @@ class LanguageService {
return langs[0]
}

var primaryLanguage = langs[0]
var primaryLanguage = ""
langs.forEach {
if (languageMap[it]!!.keywords.isNullOrEmpty()) {
if (languageMap[it]?.keywords.isNullOrEmpty()) {
primaryLanguage = it
}
}
Expand All @@ -50,7 +50,7 @@ class LanguageService {
}

fun detectLanguages(name: String): List<String> {
var language: List<String> = listOf()
val language: MutableList<String> = mutableListOf()

val dotCount = name.count { it == '.' }

Expand All @@ -65,7 +65,7 @@ class LanguageService {
}

// make others file a shebang
language = listOf(SHE_BANG)
language += SHE_BANG
}

// Lookup in case the full name matches
Expand Down
Expand Up @@ -35,4 +35,16 @@ internal class LanguageServiceTest {
val lang = LanguageService()
assertEquals("d.ts", lang.getExtension("types.d.ts"))
}

@Test
fun should_return_json_for_file() {
val lang = LanguageService()
assertEquals("JSON", lang.determineLanguage("api.json"))
}

@Test
fun should_return_empty_for_not_a_language_file() {
val lang = LanguageService()
assertEquals("", lang.determineLanguage("logo.png"))
}
}

0 comments on commit fb31740

Please sign in to comment.