aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Entities/TagExtensions.cs
blob: c1e4d1db2ffd074bb78b791fd798579028155683 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma warning disable CS1591

using System;
using System.Linq;
using Jellyfin.Extensions;

namespace MediaBrowser.Controller.Entities
{
    public static class TagExtensions
    {
        public static void AddTag(this BaseItem item, string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var current = item.Tags;

            if (!current.Contains(name, StringComparison.OrdinalIgnoreCase))
            {
                if (current.Length == 0)
                {
                    item.Tags = [name];
                }
                else
                {
                    item.Tags = [..current, name];
                }
            }
        }
    }
}