Plugin strips hyphens out of shortlink
-
I know the default behavior of YOURLS is to not allow hyphens in the shortlink, however when I enable “Allow Hyphens in Short URLs” plugin on the YOURLS server, they are still stripped out of my shortlinks in this plugin before they reach my YOURLS server.
While this is more of an edge-case scenario, it would be nice if either hyphens were added to the accepted character list:
public static function prepare_api_keyword( $string = '' ) { return preg_replace( '/[^A-Za-z0-9\-]/', '', $string ); }
or if the regex pattern could be filtered and modified by another function or plugin (so I can don’t have to modify the plugin code directly):
public static function prepare_api_keyword( $string = '' ) { $regex = '/[^A-Za-z0-9]/'; $filtered = apply_filters( 'YOURLS_shortlink_regex', $regex ); return preg_replace( $filtered', '', $string ); }
Note: These blocks of code are for reference only (to give you a starting point) and have not been fully tested.
~Cam
P.S. Thank you for a great plugin. It has made my YOURLS link creation way easier than before!
- The topic ‘Plugin strips hyphens out of shortlink’ is closed to new replies.