Skip to content

Commit 2c98530

Browse files
authored
Merge pull request #103 from aternosorg/fix-extract-plugin-name-with-dot
Fix: Extract plugin name from error message with dot in plugin name
2 parents 0da52f7 + 146237e commit 2c98530

File tree

4 files changed

+1226
-3
lines changed

4 files changed

+1226
-3
lines changed

src/Analysis/Problem/Bukkit/PluginProblem.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,21 @@ protected function correctPluginPath(string $pluginPath): string
6363
}
6464

6565
/**
66-
* Extracts the plugin name without the file extension (usually .jar) from a plugin path
66+
* Extracts the plugin name without the .jar file extension from a plugin path
6767
*
68-
* @param string $pluginPath
68+
* @param string $pluginPath Can be a path to a plugin file or a plugin name
6969
* @return string
7070
*/
7171
protected function extractPluginName(string $pluginPath): string
7272
{
73-
return pathinfo($pluginPath, PATHINFO_FILENAME);
73+
$fileName = $this->extractPluginFileName($pluginPath);
74+
// plugin names can contain a . (dot)
75+
// when using pathinfo($pluginPath, PATHINFO_FILENAME) on a plugin name with a ., the wrong plugin name would be returned.
76+
// since the file extension of a plugin is always .jar, we can simply remove it to get the plugin name from the file name.
77+
if (str_ends_with($fileName, ".jar")) {
78+
$fileName = substr($fileName, 0, -4);
79+
}
80+
return $fileName;
7481
}
7582

7683
/**

0 commit comments

Comments
 (0)