Skip to content

Commit e1f4628

Browse files
authored
Merge pull request #51 from pinanks/DOT-2923-new
Release v2.0.7
2 parents 1076b0a + 124ab01 commit e1f4628

File tree

4 files changed

+8
-34
lines changed

4 files changed

+8
-34
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "2.0.6",
3+
"version": "2.0.7",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/lib/schemaValidation.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ const ajv = new Ajv({ allErrors: true });
66
ajv.addFormat('web-url', {
77
type: 'string',
88
validate: (url: string) => {
9-
const urlPattern = new RegExp('^(https?:\\/\\/)?' + // protocol
10-
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
11-
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
12-
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
13-
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
14-
'(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
15-
return urlPattern.test(url.trim());
9+
try {
10+
new URL(url.trim());
11+
return true;
12+
} catch (error) {
13+
return false;
14+
}
1615
}
1716
});
1817
addErrors(ajv);

src/lib/screenshot.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ export async function captureScreenshots(ctx: Context, screenshots: WebStaticCon
4949
let screenshotId = screenshot.name.toLowerCase().replace(/\s/g, '-');
5050

5151
const page = await context.newPage();
52-
if(screenshot.url){
53-
screenshot.url = screenshot.url.trim();
54-
screenshot.url = ensureHttps(screenshot.url)
55-
}
56-
await page.goto(screenshot.url, pageOptions);
52+
await page.goto(screenshot.url.trim(), pageOptions);
5753

5854

5955
for (let k = 0; k < totalViewports; k++) {

src/lib/utils.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
11
import fs from 'fs';
22

3-
const HTTP_SCHEME = 'https:';
4-
const HTTP_SCHEME_PREFIX = 'https://';
5-
const WWW = 'www.';
6-
73
export function delDir(dir: string): void {
84
if (fs.existsSync(dir)) {
95
fs.rmSync(dir, { recursive: true });
106
}
117
}
128

13-
// Function to ensure URL uses HTTPS scheme
14-
export function ensureHttps(urlString: string) {
15-
try {
16-
if (urlString && urlString.startsWith(WWW)) {
17-
urlString = HTTP_SCHEME_PREFIX + urlString
18-
}
19-
let url = new URL(urlString);
20-
if (url.protocol !== HTTP_SCHEME) {
21-
url.protocol = HTTP_SCHEME;
22-
}
23-
return url.toString();
24-
} catch (error) {
25-
console.error('Invalid URL: '+urlString, error);
26-
return null;
27-
}
28-
}
29-
309
export function scrollToBottomAndBackToTop({
3110
frequency = 100,
3211
timing = 8,

0 commit comments

Comments
 (0)