Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

Limit recursion when parsing URL in document-blocked page. #24

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/js/main-blocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ uDom('.what').text(details.url);
return s;
};

const renderParams = function(parentNode, rawURL) {
// https://github.com/geekprojects/nuTensor/issues/23
// Limit recursion.
const renderParams = function(parentNode, rawURL, depth = 0) {
const a = document.createElement('a');
a.href = rawURL;
if ( a.search.length === 0 ) { return false; }
Expand All @@ -109,9 +111,9 @@ uDom('.what').text(details.url);
const name = safeDecodeURIComponent(param.slice(0, pos));
const value = safeDecodeURIComponent(param.slice(pos + 1));
const li = liFromParam(name, value);
if ( reURL.test(value) ) {
if ( depth < 2 && reURL.test(value) ) {
const ul = document.createElement('ul');
renderParams(ul, value);
renderParams(ul, value, depth + 1);
li.appendChild(ul);
}
parentNode.appendChild(li);
Expand Down