diff --git a/src/Plugin.js b/src/Plugin.js index 6c2fed6..a74f88f 100644 --- a/src/Plugin.js +++ b/src/Plugin.js @@ -5,7 +5,7 @@ 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); + const cells = _str.match(/([A-Z]+(?=[A-Z]))|([A-Z]?[^A-Z]+)/g) || []; return cells.map(c => c.toLowerCase()).join(symbol); } diff --git a/test/fixtures/qr-code/actual.js b/test/fixtures/qr-code/actual.js new file mode 100644 index 0000000..62c1d3b --- /dev/null +++ b/test/fixtures/qr-code/actual.js @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000..1f747ba --- /dev/null +++ b/test/fixtures/qr-code/expected.js @@ -0,0 +1,7 @@ +import _QRCode from "antd/lib/qr-code"; +switch (_QRCode) { + case _QRCode: + console.log('foo'); + default: + console.log('bar'); +} \ No newline at end of file