From upstream: https://github.com/docker/distribution/commit/a683c7c235e12a0dd0f03b64f8c41f06e1bd23bc