Download spectrum/shared/test/normalize-url.test.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 813 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/test/normalize-url.test.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/shared/test/normalize-url.test.js
-
curl -L -o normalize-url.test.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/test/normalize-url.test.js
813 Bytes
| // @flow | |
| import normalizeUrl from '../normalize-url'; | |
| type Input = string; | |
| type Output = string; | |
| // If only Input is provided it tests for input === output | |
| type TestCase = [Input, Output]; | |
| type TestCases = { | |
| [testName: string]: TestCase, | |
| }; | |
| const testCases: TestCases = { | |
| 'should do nothing to https URLs': [ | |
| 'https://github.com', | |
| 'https://github.com', | |
| ], | |
| 'should do nothing to http URLs': ['http://github.com', 'http://github.com'], | |
| 'should add https:// in front of URLs without protocol': [ | |
| 'github.com', | |
| 'https://github.com', | |
| ], | |
| 'should block malicious links': [ | |
| 'javascript:alert(document.cookie)', | |
| 'about:blank', | |
| ], | |
| }; | |
| Object.keys(testCases).forEach(name => { | |
| it(name, () => { | |
| expect(normalizeUrl(testCases[name][0])).toEqual(testCases[name][1]); | |
| }); | |
| }); | |