Refactory getURLStem() and fixing issue #923
Refactory getURLStem() and fixing issue #923