View | Details | Raw Unified | Return to bug 37681
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-3 / +17 lines)
Lines 621-630 Link Here
621
                    let nodes = '';
621
                    let nodes = '';
622
                    if ( row.uri.split(' \| ').length > 1 ) {
622
                    if ( row.uri.split(' \| ').length > 1 ) {
623
                        row.uri.split(' \| ').forEach((uri, i) => {
623
                        row.uri.split(' \| ').forEach((uri, i) => {
624
                            nodes += '<a href="%s">%s</a><br/>'.format(escape_str(uri), escape_str(uri));
624
                            let node = safe_link(uri,uri);
625
                            nodes += node.outerHTML + "<br>";
625
                        });
626
                        });
626
                    } else {
627
                    } else {
627
                        nodes += '<a href="%s">%s</a><br/>'.format(escape_str(row.uri), escape_str(url_link_text));
628
                        let node = safe_link(row.uri,url_link_text);
629
                        nodes += node.outerHTML;
628
                    }
630
                    }
629
                    return nodes;
631
                    return nodes;
630
                }
632
                }
Lines 834-838 Link Here
834
836
835
        return items_table;
837
        return items_table;
836
    }
838
    }
839
    function safe_link(uri,link_text) {
840
        let node = document.createElement('a');
841
        let url_str = '#';
842
        try {
843
            const safe_url = new URL(uri);
844
            url_str = safe_url.href;
845
        } catch (e) {
846
            //console.error('Invalid URL:', e);
847
        }
848
        node.setAttribute('href',url_str);
849
        node.textContent = link_text;
850
        return node;
851
    }
837
</script>
852
</script>
838
[% END %]
853
[% END %]
839
- 

Return to bug 37681