omniJS script url encoding – JS encodeURIComponent not enough?

I have been using the standard JavaScript encodeURIComponent to create omniJS URLs, apparently without problem, so I was interested to notice, at:

A script roughly along ES6-equivalent lines of:

// encodeForOmniJS :: String -> String -> String
const encodeForOmniJS = (OmniAppName, scriptCode) =>
    OmniAppName.toLowerCase() + ":///omnijs-run?script=" +
    .reduce((a, x) =>
            RegExp('\\' + x, 'g'), '%' + (x.charCodeAt(0)

Which adds a second pass after encodeURIComponent – also encoding the six extra characters: '()!~.

Should I be doing this too ? (These are characters which don’t usually need encoding in a URL)

Or, getting the Babel JS repl at to automatically convert from the ES6-compliant JS used by Sierra, to the mainly ES5-level JS of earlier macOS versions:

// encodeForOmniJS :: String -> String -> String
function encodeForOmniJS(OmniAppName, scriptCode) {
    return OmniAppName.toLowerCase() + ":///omnijs-run?script=" +
        .reduce(function (a, x) {
            return a.replace(RegExp('\\' + x, 'g'), '%' + x.charCodeAt(0)
        }, encodeURIComponent(scriptCode));