mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 20:55:35 +03:00
f1b79e0cd3
The slugify function is used to convert input into URL-friendly slugs. It processes each character in the input, keeping ascii alpha characters after lowercase and replacing non-alphanum characters with the glue character or a space if multiple spaces are encountered consecutively. The resulting string is trimmed of leading and trailing whitespace, and any internal whitespace is replaced with the glue character. It is currently used in LibMarkdown headings generation code.
18 lines
277 B
C++
18 lines
277 B
C++
/*
|
|
* Copyright (c) 2023, Gurkirat Singh <tbhaxor@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/String.h>
|
|
|
|
namespace AK {
|
|
ErrorOr<String> slugify(String const& input, char glue = '-');
|
|
}
|
|
|
|
#if USING_AK_GLOBALLY
|
|
using AK::slugify;
|
|
#endif
|