JSFiddle - React, Tailwind, and code Playground
JavaScript
var testes = ['exemplo.com/ola/', 'http://exemplo.com/', 'http://exemplo.com/ola/'];
function tem3BarrasA(url) {
return url.split('/').length > 3;
}
function tem3BarrasB(url) {
var doubleBar = url.indexOf('//');
if (doubleBar != -1) url = url.slice(doubleBar + 2);
return url.split('/').length > 2;
}
testes.forEach(function (teste) {
console.log('A', teste, tem3BarrasA(teste));
console.log('B', teste, tem3BarrasB(teste));
});