I don't think it should necessarily be a mitigating factor; but I do think that someone with addiction problems should be helped to get over them. Not always instead of punishment, but sometimes as part of them.
In the case of a serious crime, with victims who have been hurt, then the detox should happen in jail (with medical supervision); but if not, then I think a community sentence with compulsory therapy is more appropriate.
From what I understand, a lot of people who go to jail with no addiction problems come out addicted, so it will presumably be worse for those who are already on drugs or alcoholic.
I think that it shouldn't be the case that an addict is given a more lenient sentence than a non-addict committing the same crime; but addiction should be taken into consideration and treated (as far as possible) to prevent recidivism.