-
-
Save krishnaarava/c2ba03bd19bb6bbd3c6ab6e16c7dd2c9 to your computer and use it in GitHub Desktop.
SLUG URL POSTGRE FUNCTION
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION url_slug ( | |
s_texto text | |
) | |
RETURNS varchar AS | |
$body$ | |
DECLARE | |
total integer; | |
BEGIN | |
s_texto := regexp_replace(translate(replace(lower(s_texto), ' ', '-'), | |
'áàâãäåāăąÁÂÃÄÅĀĂĄèééêëēĕėęěĒĔĖÉĘĚìíîïìĩīĭÌÍÎÏÌĨĪĬóôõöōŏőÒÓÔÕÖŌŎŐùúûüũūŭůÙÚÛÜŨŪŬŮçÇÿ&,.ñÑ', | |
'aaaaaaaaaaaaaaaaaeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiooooooooooooooouuuuuuuuuuuuuuuuccy_--nn'), E'[^\\w -]', '', 'g'); | |
RETURN s_texto; | |
END; | |
$body$ | |
LANGUAGE 'plpgsql' | |
VOLATILE | |
CALLED ON NULL INPUT | |
SECURITY DEFINER | |
COST 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment