Yourls: how to make plugin to accept url in other scheme than http or https

262 views Asked by At

Default Yourls doesn't allow url to be shorten in other scheme than http or https. But I want it to accept them, too. I am going to implement by adding custom plugin.

there is a function evaluating url input by users as bellow.

includes\functions.php

function yourls_add_new_link( $url, $keyword = '', $title = '' ) {
    // Allow plugins to short-circuit the whole function
    $pre = yourls_apply_filter( 'shunt_add_new_link', false, $url, $keyword, $title );
    if ( false !== $pre )
        return $pre;

    $url = yourls_encodeURI( $url );
    $url = yourls_sanitize_url( $url );
    if ( !$url || $url == 'http://' || $url == 'https://' ) {
        $return['status']    = 'fail';
        $return['code']      = 'error:nourl';
        $return['message']   = yourls__( 'Missing or malformed URL' );
        $return['errorCode'] = '400';
        return yourls_apply_filter( 'add_new_link_fail_nourl', $return, $url, $keyword, $title );
    }

I just don't know whether I can make it to allow other url scheme by adding plugin or not. Do you have any idea?

0

There are 0 answers