JSFiddle - React, Tailwind, and code Playground
HTML
<a href="test.pdf">test</a>
<a href="http://example.com/test.pdf">test</a>
<button type="button">Check hrefs!</button>
JavaScript
$('a[href$=".pdf"]').not('a[href^="http"]').attr('href', function(i, val) { return 'pdf/' + val });
$('button').click(function() {
$('a').each(function() { alert($(this).attr('href')) });
});