Code
function out = is_double_url(url_path1)
if url_path1(end)~='/'
url_path1(end+1)='/';
end
url_path1 = regexprep(url_path1,'//','//www.');
url_path1 = regexprep(url_path1,'//www.www.','//www.');
f1 = strfind(url_path1,'www.');
if numel(f1)<2
out = false;
else
f2 = strfind(url_path1,'/');
f3 = bsxfun(@minus,f2,f1');
count_dots = zeros(size(f3,1),1);
for k = 1:size(f3,1)
[~,y] = find(f3(k,:)>0,1);
str2 = url_path1(f1(k):f2(y));
if ~isempty(strfind(str2,'..'))
continue
end
count_dots(k) = nnz(strfind(str2,'.'));
end
out = ~any(count_dots(2:end)<2);
if any(strfind(url_path1,'://')>f2(1))
out = true;
end
end
return;
Runs
is_double_url('http://www.farthingalescorsetmakingsupplies.com/files/files/www.apple.com/')
is_double_url('http://www.farthingalescorsetmakingsupplies.com/files/files/www.com/')
is_double_url('http://www.farthingalescorsetmakingsupplies.com/files/files/https://www.com/')
is_double_url('http://www.farthingalescorsetmakingsupplies.com/files/files/https://www.dfdsf.my/')
Returns - 1 0 1 1 respectively.
If you have a list of URLs in a text file , use this to do checking for each of them -
fid = fopen('text2.txt'); %% 'text2.txt' has the urls on line by line basis
C = textscan(fid, '%s\n');
fclose(fid);
for k = 1:numel(C{1})
out(k) = is_double_url(C{1}{k}); %%// out stores the condition checked statuses
end