🔨 Refactor: plugin name -> fullName to support scope packages

This commit is contained in:
PiEgg
2020-12-26 23:39:48 +08:00
parent 064f37d1a6
commit 2129f86266
4 changed files with 45 additions and 23 deletions

View File

@@ -15,3 +15,18 @@ export const handleUrlEncode = (url: string): string => {
}
return url
}
/**
* streamline the full plugin name to a simple one
* for example:
* 1. picgo-plugin-xxx -> xxx
* 2. @xxx/picgo-plugin-yyy -> yyy
* @param name pluginFullName
*/
export const handleStreamlinePluginName = (name: string) => {
if (/^@[^/]+\/picgo-plugin-/.test(name)) {
return name.replace(/^@[^/]+\/picgo-plugin-/, '')
} else {
return name.replace(/picgo-plugin-/, '')
}
}