This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello World! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fallbackCopyToClipboard = (text) => { | |
const textArea = document.createElement('textarea'); | |
textArea.value = text; | |
textArea.style.top = '0'; | |
textArea.style.left = '0'; | |
textArea.style.position = 'fixed'; | |
document.body.appendChild(textArea); | |
textArea.focus(); | |
textArea.select(); | |
document.execCommand('copy'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const regExp = new RegExp('^(?:[a-z]+:)?//', 'i'); | |
regExp.test('http://example.com'); // true - regular http absolute URL | |
regExp.test('HTTP://EXAMPLE.COM'); // true - HTTP upper-case absolute URL | |
regExp.test('https://www.exmaple.com'); // true - secure http absolute URL | |
regExp.test('ftp://example.com/file.txt'); // true - file transfer absolute URL | |
regExp.test('//cdn.example.com/lib.js'); // true - protocol-relative absolute URL | |
regExp.test('/myfolder/test.txt'); // false - relative URL | |
regExp.test('test'); // false - also relative URL |