Search code examples
javascriptnode.jsslugify

How can I convert a string slugify in the equivalent in human


I want transform a string that it is slugified in another string that it is the equivalent in human readable?

I take the parametesr from an url:

bookmark/10/disco%20asdasd

So I have the nome that is "disco%20asdasd". But in this way it not confrontable so I need to convert "disco%20asdasd" in "disco asdasd" that is the operation opposite to slugify. Anyone can help me?


Solution

  • It would really help if you showed an example of a string that you want to convert and an example of a string that you want to convert it to. Without that I can only recommend you some general solutions. See:

    See the code examples in the docs of those projects.

    Update

    If you want to convert: disco%20asdasd to: disco asdasd then use:

    let decoded = decodeURI(yourString);
    

    or:

    let decoded = decodeURIComponent(yourString);
    

    but this is not a slug - this is URI-encoding and decoding.

    See:

    More info on Wikipedia: