All Projects → ctolkien → Slugify

ctolkien / Slugify

Licence: MIT License
Simple Slug / Clean URL generator helper for Microsoft .NET framework / .NET Standard.

Programming Languages

C#
18002 projects
HTML
75241 projects

Projects that are alternatives of or similar to Slugify

mongoose-slug-updater
Schema-based slug plugin for Mongoose - single/compound - unique over collection/group - nested docs/arrays - relative/abs paths - sync on change: create/save/update/updateOne/updateMany/findOneAndUpdate tracked - $set operator - counter/shortId
Stars: ✭ 37 (-30.19%)
Mutual labels:  url, slugify
django-slugs-example-app
A basic app to show how to add slugs to models
Stars: ✭ 12 (-77.36%)
Mutual labels:  url, slugify
Workday.WebServices
Workday API clients
Stars: ✭ 18 (-66.04%)
Mutual labels:  dotnet-standard
pem-utils
Managed .NET (C#) utility library for working with PEM files with DER/ASN.1 encoding
Stars: ✭ 62 (+16.98%)
Mutual labels:  dotnet-standard
wumpfetch
🚀🔗 A modern, lightweight, fast and easy to use Node.js HTTP client
Stars: ✭ 20 (-62.26%)
Mutual labels:  url
HardwareInformation
.NET Standard Cross-Platform Hardware Information Gatherer
Stars: ✭ 37 (-30.19%)
Mutual labels:  dotnet-standard
URL-Magnet-Cloud-Uploader-Heroku
Aria 2 Rclone Remote URL /magnet Clouds upload via HEROKU
Stars: ✭ 99 (+86.79%)
Mutual labels:  url
WebDavClient
Asynchronous cross-platform WebDAV client for .NET Core
Stars: ✭ 98 (+84.91%)
Mutual labels:  dotnet-standard
git-repo-name
Get the repository name from the git remote origin URL
Stars: ✭ 21 (-60.38%)
Mutual labels:  url
UrlCombine
C# util for combining Url paths. Works similarly to Path.Combine.
Stars: ✭ 23 (-56.6%)
Mutual labels:  url
Okanshi
mvno.github.io/okanshi
Stars: ✭ 14 (-73.58%)
Mutual labels:  dotnet-standard
micell
A collection of functions for front-end development
Stars: ✭ 16 (-69.81%)
Mutual labels:  url
urlshortener-rs
A very-very simple url shortener for Rust
Stars: ✭ 34 (-35.85%)
Mutual labels:  url
Mutatio
Visual Studio for Mac add-in/extension for converting old PCLs to .NET Standard 2.0 targeting projects automatically.
Stars: ✭ 27 (-49.06%)
Mutual labels:  dotnet-standard
utils.js
👷 🔧 zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-73.58%)
Mutual labels:  url
oryx
.NET Cross platform and highly composable middleware for building web request handlers in F#
Stars: ✭ 178 (+235.85%)
Mutual labels:  dotnet-standard
chatbase-dotnet
Integrate your DotNet application with Chatbase!
Stars: ✭ 16 (-69.81%)
Mutual labels:  dotnet-standard
URLQueryItemEncoder
A Swift Encoder for encoding any Encodable value into an array of URLQueryItem.
Stars: ✭ 60 (+13.21%)
Mutual labels:  url
quill-magic-url
Automatically convert URLs to links in Quill
Stars: ✭ 86 (+62.26%)
Mutual labels:  url
doi2bib
📝 Easily convert Digital Object Identifier (DOI) and Uniform Resource Locator (URL) to BibTeX and DOI to plain text.
Stars: ✭ 28 (-47.17%)
Mutual labels:  url

Slugify Core

This is a fork of the original project here: https://github.com/fcingolani/Slugify. This has been updated for .NET Standard 2.0 support (older versions support .NET Standard down to 1.3).

.NET Version license

Simple Slug / Clean URL generator helper for Microsoft .NET framework.

With default settings, you will get an hyphenized, lowercase, alphanumeric version of any string you please, with any diacritics removed and collapsed whitespace, collapsed dashes and trimmed whitespace.

In example, having:

a ambição cerra o coração

You'll get:

a-ambicao-cerra-o-coracao

Installation

You can get the Slugify NuGet package by running the following command in the Package Manager Console:

PM> Install-Package Slugify.Core

Upgrading from 2.x to 3.x

  • 3.0 is a significantly faster and less memory intensive version of the Slugifier. Whilst effort has been made to maintain backwards compatability, there may be some breaking changes.
  • The SlugHelper.Config nested class has been renamed to just SlugHelperConfiguration.

Basic Usage

It's really simple! Just instantiate SlugHelper and call its GenerateSlug with the string you want to convert; it'll return the URL Safe version:

using Slugify;

public class MyApp
{
   public static void Main()
   {
      SlugHelper helper = new SlugHelper();

      String title = "OLA ke ase!";

      String slug = helper.GenerateSlug(title); // "ola-ke-ase"

      Console.WriteLine(slug);
   }
}

Configuration

You can provide a SlugHelperConfiguration instance to SlugHelper's constructor to customize the helper's behavior:

// Creating a configuration object
var config = new SlugHelperConfiguration();

// Replace spaces with a dash
config.StringReplacements.Add(" ", "-");

// We want a lowercase Slug
config.ForceLowerCase = true;

// Will collapse multiple seqential dashes down to a single one
config.CollapseDashes = true;

// Will trim leading and trailing whitespace
config.TrimWhitespace = true;

// Colapse consecutive whitespace chars into one
config.CollapseWhiteSpace = true;

// Remove everything that's not a letter, number, hyphen, dot, or underscore
config.DeniedCharactersRegex = @"[^a-zA-Z0-9\-\._]";

// Create a helper instance with our new configuration
SlugHelper helper = new SlugHelper(config);

In fact, the above values are so common they're the default ones! So last code could be rewritten as:

var config = new SlugHelperConfiguration();
SlugHelper helper = new SlugHelper(config);

One more thing: SlugHelperConfiguration is used when you call the parameterless SlugHelper constructor. Then ...

SlugHelper helper = new SlugHelper();

... is the same as running the code we had in first place.

Options

CharacterReplacements

Type: Dictionary<String, String>. Default: [" ": "-"].

Will replace the specified keys with their associated value.

By default, will replace spaces with hyphens.

ForceLowerCase

Type: Boolean. Default: true.

Setting it to true will convert output string to be LowerCase. If false, original casing will be preserved.

CollapseWhiteSpace

Type: Boolean. Default: true.

Setting it to true will replace consecutive whitespace characters by just one space (" ").

DeniedCharactersRegex

Type: String. Default: [^a-zA-Z0-9\-\._].

Any character matching this Regular Expression will be deleted from the resulting string.

CollapseDashes

Type: Boolean. Default: true

This will condense multiple dashes (e.g. foo---bar) down to a single dash (foo-bar). This is useful to avoid scenarios like foo & bar becoming foo--bar.

License

The MIT License (MIT)

Copyright (c) 2013 Federico Cingolani

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].