Support scanning name where ":" is contained within (#354)

This commit is contained in:
Jaco Greeff
2020-08-10 21:26:11 +02:00
committed by GitHub
parent 8766481109
commit fdc310b32e
11 changed files with 111 additions and 94 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ function ScanAddress ({ className, onError, onScan, size, style }: Props): React
(data: string | null): void => {
if (data) {
try {
const [prefix, content, genesisHash, name] = data.split(':');
const [prefix, content, genesisHash, ...name] = data.split(':');
const isValidPrefix = prefix === ADDRESS_PREFIX || prefix === SEED_PREFIX;
assert(isValidPrefix, `Invalid prefix received, expected '${ADDRESS_PREFIX}/${SEED_PREFIX}' , found '${prefix}'`);
@@ -40,7 +40,7 @@ function ScanAddress ({ className, onError, onScan, size, style }: Props): React
decodeAddress(content);
}
onScan({ content, genesisHash, isAddress, name });
onScan({ content, genesisHash, isAddress, name: name?.length ? name.join(':') : undefined });
} catch (error) {
console.error('@polkadot/react-qr:QrScanAddress', (error as Error).message, data);
}