UTI while 5 weeks pregnant

Jordan

I had spotting one time when I went to the restroom today at work around 1. Didn’t have any pain or cramps, just that one time pink spotting.. I came to the hospital to be on the safe side.. the baby is fine & looks great as where I should be for 5 weeks.. but, my urine came back as UTI.. I was prescribed medication & was told it’s safe to take while pregnant.. have any of you ladies had a UTI while being this early at 5 weeks in pregnancy? Was it safe to take the medication they prescribed?