You don't say. Right now I'm trying to buy a new cable to charge my XPS 15, I already bought 2 not working.
At least in the past it was easy to eyeball the connectors and pick the right cable.
Previous post from last year on the subject about his work: https://news.ycombinator.com/item?id=10508494