Loop when 3rd party equipment is in btween?

I have 30 cn Matrix switches connected in a chain.

TX (1)+TX (2) +TX (3)+TX (4) + 3RD PARTY ROUTER +TX (5) +TX (6)+TX (7) +TX (8)+TX (…) +

So you see between TX (4) and TX(5) there is a router. We are also using spanning tree protocol.

TX(4) in addition to being connected to the router is also connected directly to TX(5).

Will spanning tree protocol know not to create a loop?