Class PathUtils

    • Method Detail

      • simplify

        @Nonnull
        public static String simplify​(String part)
        Simplifies a path part. The resulting string only contains numbers ([0-9]) and lowercase characters ([a-z]). One ore more consecutive whitespaces or a few non-ascii characters are converted into a single dash '-'. All other characters are either converted to ASCII characters, or removed.

        This method can be used to convert e.g. titles into URL parts, for search engine optimization.

        On accented characters, the accent is removed. However, currently German umlauts are converted into their respective ASCII counterparts ('ä' -> 'ae'). Future implementations may also contain translations for other language's accented characters.

        Consider this method as one-way encoding. Future releases may return different strings.

        Parameters:
        part - path part to simplify
        Returns:
        simplified path part
      • suffix

        @Nonnull
        public static String suffix​(String mime)
        Suggests a file name suffix for the given content type.

        The current implementation only detects the standard HTML image types.

        Parameters:
        mime - content type to find a suffix for
        Returns:
        suggested suffix, or "bin" if there is no known suffix