-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.js
More file actions
56 lines (45 loc) · 2 KB
/
demo.js
File metadata and controls
56 lines (45 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Demo file to specifically demonstrate IDEA.MD requirements
* 1. Checks Single URL validity, availability, potential risks - return True if Safe or else False
* 2. Checks the above things for an array of URLs - Return a dictionary of True Or False based on the above checks
*/
import { checkUrl, checkUrls } from './index.js';
async function demo() {
console.log('=== IDEA.MD Requirements Demo ===\n');
console.log('Requirement 1: Single URL Check');
console.log('Check validity, availability, and potential risks');
console.log('Return Boolean (True if Safe, False otherwise)\n');
// Test safe URL
const url1 = 'https://www.example.com';
const result1 = await checkUrl(url1, { checkAvailability: false });
console.log(`checkUrl("${url1}")`);
console.log(`Result: ${result1} (Boolean)\n`);
// Test unsafe URL
const url2 = 'javascript:alert(1)';
const result2 = await checkUrl(url2, { checkAvailability: false });
console.log(`checkUrl("${url2}")`);
console.log(`Result: ${result2} (Boolean)\n`);
console.log('---\n');
console.log('Requirement 2: Array of URLs Check');
console.log('Check validity, availability, and potential risks for multiple URLs');
console.log('Return Dictionary (String:Bool pairs)\n');
const urlArray = [
'https://www.google.com',
'https://example.com',
'invalid-url',
'javascript:void(0)',
'http://suspicious.tk',
'https://github.com'
];
const results = await checkUrls(urlArray, { checkAvailability: false });
console.log('checkUrls([...])');
console.log('Result: Dictionary/Object with String:Bool pairs\n');
console.log(JSON.stringify(results, null, 2));
console.log('\n=== Requirements Satisfied ===');
console.log('✓ Single URL returns Boolean value');
console.log('✓ Array of URLs returns String:Bool Dictionary');
console.log('✓ Checks URL validity');
console.log('✓ Checks URL availability (when enabled)');
console.log('✓ Checks potential security risks');
}
demo().catch(console.error);