javascript pathname fix so that it can work on deployed environment