diff --git a/src/main/kotlin/app/extractors/Heuristics.kt b/src/main/kotlin/app/extractors/Heuristics.kt index 6da1eae5..70ce3be4 100644 --- a/src/main/kotlin/app/extractors/Heuristics.kt +++ b/src/main/kotlin/app/extractors/Heuristics.kt @@ -122,6 +122,9 @@ val Perl6Regex = Regex( val PhpRegex = Regex( "^<\\?(?:php)?" ) +val PhpIlluminateRegex = Regex( + "(Auth|Bootstrap|Bus|Console|Events|Exceptions|Http|Providers" + + "|Support|Testing|Validation)") val PicoLispRegex = Regex( "^\\((de|class|rel|code|data|must)\\s", RegexOption.MULTILINE @@ -235,6 +238,11 @@ val k8sExp = { buf: String -> && buf.contains("metadata") } +val bootstrapWebpackExp = { buf: String -> + // Handling php projects with bootstrap Webpack. + buf.contains("/******/ (function(modules) { // webpackBootstrap") +} + /** * Heuristics to detect a programming language by file extension and content. * Inspired by GitHub Liguist heuristics (https://github.com/github/linguist). @@ -638,8 +646,11 @@ val HeuristicsMap = mapOf ExtractorInterface?>( "jl" to { _, _ -> CommonExtractor(Lang.JULIA) }, - "js" to { _, _ -> - JavascriptExtractor() + "js" to { buf, _ -> + if (bootstrapWebpackExp(buf)) { + null + } + else JavascriptExtractor() }, "jsx" to { _, _ -> JavascriptExtractor() @@ -793,10 +804,13 @@ val HeuristicsMap = mapOf ExtractorInterface?>( "pde" to { _, _ -> CommonExtractor(Lang.PROCESSING) }, - "php" to { buf, _ -> + "php" to { buf, path -> if (buf.contains("