Skip to content

Instantly share code, notes, and snippets.

View demikhovr's full-sized avatar
🎯
Focusing

Rodion Demikhov demikhovr

🎯
Focusing
  • Emerging Travel Group
View GitHub Profile
Hello World!
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');
@demikhovr
demikhovr / gist.js
Last active April 24, 2019 09:39
Check absolute URL
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