This is not always true, since during the pregnancy, the mother's body is helping the baby's get rid of drug. However, if the concern is for the baby's merely getting exposed to a drug, say an antidepressant, then the baby is getting exposed to much more drug at a more sensitive time during pregnancy than during breastfeeding. They are not absorbed from the stomach or intestines. These include many, but not all, drugs given by injection. They are not excreted into the milk.
Some drugs are just too big to get into the milk.
Examples are heparin, interferon, insulin. Thus, a baby born to a mother on this drug during the pregnancy, will have large amounts in his body, and even the small amount added during breastfeeding may result in significant accumulation and side effects. These are rare, but have happened. In this way, you will eliminate the drug from your body and so will the baby. Drugs for local or regional anaesthesia are not absorbed from the baby's stomach and are safe.