Refactored URL munging to use IntelliJ API calls when available