The sole folklore-related Google Books result from the 19th century containing both "rainbow"and"rainbow" and "leprechaun" comes from Irish Melodies, a compendium of poems by Thomas Moore, but a look at the actual page is disappointing: the end of one poem mentions a rainbow while a footnote to the next poem mentions a leprechaun. It's just a typographical coincidence.
Thorpe refers to Mimir's well, which lies near the Jotunheim end of the rainbow bridge Bifrost. No leprechauns here.
Children believe at this day that a golden cup or bag of gold lies at the end of a rainbow. The story comes from the ancient sun-myth so widely diffused, of the golden orb sinking into the waters of ocean or stream or lake. In one transformation it was the legend of a golden treasure buried in the Rhine, as we have it in the Niebelungen Lay, then finally, changed as it is in the nursery tale, we see the old myth again. No leprechauns here, either.
This book does not contain the word "leprechaun".
Notice it's not said the gold was found at the end of the rainbow...instead, Finian brought the gold to the end of the rainbow. Nevertheless the opening number "Look To The Rainbow" uses following thethe rainbow as a metaphor for following a dream to be followed. All of the elements swirl together and it looks like that's how this entered popular folklore.