electron-141: fixes the url validation issue for both mac and windows

This commit is contained in:
Vishwas Shashidhar 2017-10-09 19:29:05 +05:30
parent e0f03011ae
commit 89bbcfde61
7 changed files with 28 additions and 20 deletions

View File

@ -6,7 +6,7 @@
<dict>
<key>Resources/Base.lproj/MyInstallerPane.nib</key>
<data>
qiy2hXJXysWzBheRqmrAbjhaIAo=
TF/AqkGdS25ttnHMS1l76ES81/w=
</data>
<key>Resources/InstallerSections.plist</key>
<data>
@ -37,11 +37,11 @@
<dict>
<key>hash</key>
<data>
qiy2hXJXysWzBheRqmrAbjhaIAo=
TF/AqkGdS25ttnHMS1l76ES81/w=
</data>
<key>hash2</key>
<data>
cbetu00//tMoZxaT60nKX2nVQaxpcuLAQbBqwG/xCeo=
gxXMI4SoTYE7jYkP5QJ7i804TUXR4x8LGSh99n9qers=
</data>
</dict>
<key>Resources/InstallerSections.plist</key>

View File

@ -75,7 +75,7 @@
<textField toolTip="Ex: https://my.symphony.com" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uwa-xi-M5X">
<rect key="frame" x="196" y="197" width="207" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" placeholderString="Ex: https://my.symphony.com" drawsBackground="YES" id="5g9-ba-etY">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="left" title="https://corporate.symphony.com" placeholderString="Ex: https://corporate.symphony.com" drawsBackground="YES" id="5g9-ba-etY">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>

View File

@ -7,7 +7,7 @@
#import <InstallerPlugins/InstallerPlugins.h>
@interface MyInstallerPane : InstallerPane
@interface MyInstallerPane : InstallerPane<NSTextFieldDelegate>
@property (weak) IBOutlet NSButton *minimizeOnCloseCheckBox;
@property (weak) IBOutlet NSButton *autoLaunchCheckBox;

View File

@ -14,20 +14,23 @@
return [[NSBundle bundleForClass:[self class]] localizedStringForKey:@"PaneTitle" value:nil table:nil];
}
- (void)willEnterPane:(InstallerSectionDirection)dir {
[_podUrlAlertTextBox setTitleWithMnemonic:@""];
}
- (BOOL)shouldExitPane:(InstallerSectionDirection)dir {
NSString *regex = @"^((?:http:\/\/)|(?:https:\/\/))(www.)?((?:[a-zA-Z0-9]+\.[a-z]{3})|(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?::\d+)?))([\/a-zA-Z0-9\.]*)$";
NSString *podUrl = [_podUrlTextBox stringValue];
NSURL *validUrl = [NSURL URLWithString:podUrl];
if (!validUrl || !validUrl.host) {
[_podUrlAlertTextBox setTitleWithMnemonic:@"Please enter a valid Pod url."];
return NO;
NSPredicate *podUrlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
if ([podUrlTest evaluateWithObject:podUrl]) {
return YES;
}
return YES;
[_podUrlAlertTextBox setTitleWithMnemonic:@"Please enter a valid Pod url."];
return NO;
}
@ -35,7 +38,7 @@
NSString *podUrl = [_podUrlTextBox stringValue];
// If the pod url is empty, by default, set it to my.symphony.com
// If the pod url is empty, by default, set it to https://corporate.symphony.com
if ([podUrl length] == 0) {
podUrl = @"https://corporate.symphony.com";
}

View File

@ -10,18 +10,23 @@ describe('download manager', function() {
});
it('should inject download bar element into DOM once download is initiated', function() {
electron.ipcRenderer.send('downloadCompleted', { _id: '12345', fileName: 'test', total: 100 });
expect(document.getElementsByClassName('text-cutoff')[0].innerHTML).toBe('test');
electron.ipcRenderer.send('downloadCompleted', { _id: '12345', fileName: 'test.png', total: 100 });
expect(document.getElementsByClassName('text-cutoff')[0].innerHTML).toBe('test.png');
expect(document.getElementById('per').innerHTML).toBe('100 Downloaded');
});
it('should inject multiple download items during multiple downloads', function() {
electron.ipcRenderer.send('downloadCompleted', { _id: '12345', fileName: 'test', total: 100 });
electron.ipcRenderer.send('downloadCompleted', { _id: '67890', fileName: 'test1', total: 200 });
electron.ipcRenderer.send('downloadCompleted', { _id: '12345', fileName: 'test.png', total: 100 });
electron.ipcRenderer.send('downloadCompleted', { _id: '67890', fileName: 'test.png', total: 200 });
let fileNames = document.getElementsByClassName('text-cutoff');
expect(fileNames[0].innerHTML).toBe('test1');
expect(fileNames[1].innerHTML).toBe('test');
let fNames = [];
for (var i = 0; i < fileNames.length; i++) {
fNames.push(fileNames[i].innerHTML);
}
expect(fNames).toEqual(expect.arrayContaining(['test (1).png', 'test (2).png']));
expect(document.getElementById('per').innerHTML).toBe('100 Downloaded');
let downloadElements = document.getElementsByClassName('download-element');