Avoid NPE when 'origin' parameter not present

NPE is thrown in `origin.trim()` line.