diff --git a/src/Plugin.js b/src/Plugin.js index a74f88f..8afe921 100644 --- a/src/Plugin.js +++ b/src/Plugin.js @@ -2,11 +2,8 @@ import { join } from 'path'; import { addSideEffect, addDefault, addNamed } from '@babel/helper-module-imports'; function transCamel(_str, symbol) { - // e.g. QRCode - // First match: QR - // Second match: Code - const cells = _str.match(/([A-Z]+(?=[A-Z]))|([A-Z]?[^A-Z]+)/g) || []; - return cells.map(c => c.toLowerCase()).join(symbol); + const str = _str[0].toLowerCase() + _str.substr(1); + return str.replace(/([A-Z])/g, $1 => `${symbol}${$1.toLowerCase()}`); } function winPath(path) { diff --git a/test/fixtures/qr-code/actual.js b/test/fixtures/qr-code/actual.js deleted file mode 100644 index 62c1d3b..0000000 --- a/test/fixtures/qr-code/actual.js +++ /dev/null @@ -1,8 +0,0 @@ -import { QRCode } from 'antd'; - -switch(QRCode){ - case QRCode: - console.log('foo'); - default: - console.log('bar') -} diff --git a/test/fixtures/qr-code/expected.js b/test/fixtures/qr-code/expected.js deleted file mode 100644 index 1f747ba..0000000 --- a/test/fixtures/qr-code/expected.js +++ /dev/null @@ -1,7 +0,0 @@ -import _QRCode from "antd/lib/qr-code"; -switch (_QRCode) { - case _QRCode: - console.log('foo'); - default: - console.log('bar'); -} \ No newline at end of file