diff --git a/doric-iOS/Devkit/Classes/DoricDevViewController.m b/doric-iOS/Devkit/Classes/DoricDevViewController.m index 1f06a76f..02d49e6e 100644 --- a/doric-iOS/Devkit/Classes/DoricDevViewController.m +++ b/doric-iOS/Devkit/Classes/DoricDevViewController.m @@ -322,8 +322,14 @@ - (void)input { style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { __strong typeof(_alert) alert = _alert; - NSString *ip = alert.textFields.lastObject.text; - [[DoricDev instance] connectDevKit:[NSString stringWithFormat:@"ws://%@:7777", ip]]; + NSString *url = alert.textFields.lastObject.text; + if (![url containsString:@":"]) { + url = [NSString stringWithFormat:@"%@:7777", url]; + } + if (![url containsString:@"://"]) { + url = [NSString stringWithFormat:@"ws://%@", url]; + } + [[DoricDev instance] connectDevKit:url]; }]; [alert addAction:okAction]; diff --git a/doric-iOS/Devkit/Classes/QRScanViewController.m b/doric-iOS/Devkit/Classes/QRScanViewController.m index aa22bc38..5fe3072d 100644 --- a/doric-iOS/Devkit/Classes/QRScanViewController.m +++ b/doric-iOS/Devkit/Classes/QRScanViewController.m @@ -101,10 +101,16 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects: [self.session stopRunning]; if ([metadataObjects count] >= 1) { AVMetadataMachineReadableCodeObject *qrObject = [metadataObjects lastObject]; - NSString *result = qrObject.stringValue; - NSLog(@"Scan result is %@", result); - [[DoricDev instance] connectDevKit:[NSString stringWithFormat:@"ws://%@:7777", result]]; - ShowToast([NSString stringWithFormat:@"Connected to %@", result], DoricGravityBottom); + NSString *url = qrObject.stringValue; + NSLog(@"Scan result is %@", url); + if (![url containsString:@":"]) { + url = [NSString stringWithFormat:@"%@:7777", url]; + } + if (![url containsString:@"://"]) { + url = [NSString stringWithFormat:@"ws://%@", url]; + } + [[DoricDev instance] connectDevKit:url]; + ShowToast([NSString stringWithFormat:@"Connected to %@", url], DoricGravityBottom); [self.navigationController popViewControllerAnimated:NO]; } }