Yes, you can repair an extension cord, but cheap ones aren't worth it.
You can replace a damaged plug or socket on an extension cord, but it only makes sense for heavy-duty cords you can’t easily replace. For a $5 hardware store cord, just buy a new one—it’s safer and usually costs less than a good replacement plug.
If you do repair one, safety is straightforward but not optional. Get a replacement plug rated for the cord’s gauge and number of conductors (most household cords are 3-prong, 16-14 gauge). Strip the jacket carefully, land the wires exactly: white (neutral) to the silver screw, black (hot) to the gold screw, green/bare (ground) to the green screw. Cramp the strain relief so the inner wires don’t pull loose. Use a polarized plug with the wider blade for neutral. Tug test before you plug it in.
What you shouldn’t do: splice a broken cord, use a plug that’s too small for the wire, skip the ground prong, or wrap electrical tape where a proper clamp should be. Those are fire starters.
For a short, flimsy cord? Toss it. For a 50