There are a lot of jobs going around these days. Employers no longer have the luxury to treat prospective hires poorly. This is the employer's problem, not the candidates.
Personally, I've asked potential hires for work product demonstrations. However, two crucial differences: 1) I paid them for their time, and 2) the task was on a real part of our infrastructure, the code they produced eventually being used in production. Everyone was happy with this situation.
I'd say that's a much more fair way to go about it. If you're going to ask someone to do work for you, that should be a paying gig, and it should be a task worth doing. If you're looking for a free sample a public repo or a task that fits within the parameters of a normal interview time would be better alternatives.
Personally, I've asked potential hires for work product demonstrations. However, two crucial differences: 1) I paid them for their time, and 2) the task was on a real part of our infrastructure, the code they produced eventually being used in production. Everyone was happy with this situation.