UNPKG

5.77 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.TagNames = exports.ErrorLevel = exports.isAllowDeny = exports.EnumAllowDeny = exports.isValidYesNo = exports.EnumYesNo = exports.isValidChangeFreq = exports.CHANGEFREQ = exports.isResolution = exports.isPriceType = exports.validators = exports.EnumChangefreq = void 0;
4/**
5 * How frequently the page is likely to change. This value provides general
6 * information to search engines and may not correlate exactly to how often they crawl the page. Please note that the
7 * value of this tag is considered a hint and not a command. See
8 * <https://www.sitemaps.org/protocol.html#xmlTagDefinitions> for the acceptable
9 * values
10 */
11var EnumChangefreq;
12(function (EnumChangefreq) {
13 EnumChangefreq["DAILY"] = "daily";
14 EnumChangefreq["MONTHLY"] = "monthly";
15 EnumChangefreq["ALWAYS"] = "always";
16 EnumChangefreq["HOURLY"] = "hourly";
17 EnumChangefreq["WEEKLY"] = "weekly";
18 EnumChangefreq["YEARLY"] = "yearly";
19 EnumChangefreq["NEVER"] = "never";
20})(EnumChangefreq = exports.EnumChangefreq || (exports.EnumChangefreq = {}));
21const allowDeny = /^(?:allow|deny)$/;
22exports.validators = {
23 'price:currency': /^[A-Z]{3}$/,
24 'price:type': /^(?:rent|purchase|RENT|PURCHASE)$/,
25 'price:resolution': /^(?:HD|hd|sd|SD)$/,
26 'platform:relationship': allowDeny,
27 'restriction:relationship': allowDeny,
28 restriction: /^([A-Z]{2}( +[A-Z]{2})*)?$/,
29 platform: /^((web|mobile|tv)( (web|mobile|tv))*)?$/,
30 language: /^zh-cn|zh-tw|([a-z]{2,3})$/,
31 genres: /^(PressRelease|Satire|Blog|OpEd|Opinion|UserGenerated)(, *(PressRelease|Satire|Blog|OpEd|Opinion|UserGenerated))*$/,
32 stock_tickers: /^(\w+:\w+(, *\w+:\w+){0,4})?$/,
33};
34function isPriceType(pt) {
35 return exports.validators['price:type'].test(pt);
36}
37exports.isPriceType = isPriceType;
38function isResolution(res) {
39 return exports.validators['price:resolution'].test(res);
40}
41exports.isResolution = isResolution;
42exports.CHANGEFREQ = Object.values(EnumChangefreq);
43function isValidChangeFreq(freq) {
44 return exports.CHANGEFREQ.includes(freq);
45}
46exports.isValidChangeFreq = isValidChangeFreq;
47var EnumYesNo;
48(function (EnumYesNo) {
49 EnumYesNo["YES"] = "YES";
50 EnumYesNo["NO"] = "NO";
51 EnumYesNo["Yes"] = "Yes";
52 EnumYesNo["No"] = "No";
53 EnumYesNo["yes"] = "yes";
54 EnumYesNo["no"] = "no";
55})(EnumYesNo = exports.EnumYesNo || (exports.EnumYesNo = {}));
56function isValidYesNo(yn) {
57 return /^YES|NO|[Yy]es|[Nn]o$/.test(yn);
58}
59exports.isValidYesNo = isValidYesNo;
60var EnumAllowDeny;
61(function (EnumAllowDeny) {
62 EnumAllowDeny["ALLOW"] = "allow";
63 EnumAllowDeny["DENY"] = "deny";
64})(EnumAllowDeny = exports.EnumAllowDeny || (exports.EnumAllowDeny = {}));
65function isAllowDeny(ad) {
66 return allowDeny.test(ad);
67}
68exports.isAllowDeny = isAllowDeny;
69/**
70 * How to handle errors in passed in urls
71 */
72var ErrorLevel;
73(function (ErrorLevel) {
74 /**
75 * Validation will be skipped and nothing logged or thrown.
76 */
77 ErrorLevel["SILENT"] = "silent";
78 /**
79 * If an invalid value is encountered, a console.warn will be called with details
80 */
81 ErrorLevel["WARN"] = "warn";
82 /**
83 * An Error will be thrown on encountering invalid data.
84 */
85 ErrorLevel["THROW"] = "throw";
86})(ErrorLevel = exports.ErrorLevel || (exports.ErrorLevel = {}));
87var TagNames;
88(function (TagNames) {
89 TagNames["url"] = "url";
90 TagNames["loc"] = "loc";
91 TagNames["urlset"] = "urlset";
92 TagNames["lastmod"] = "lastmod";
93 TagNames["changefreq"] = "changefreq";
94 TagNames["priority"] = "priority";
95 TagNames["video:thumbnail_loc"] = "video:thumbnail_loc";
96 TagNames["video:video"] = "video:video";
97 TagNames["video:title"] = "video:title";
98 TagNames["video:description"] = "video:description";
99 TagNames["video:tag"] = "video:tag";
100 TagNames["video:duration"] = "video:duration";
101 TagNames["video:player_loc"] = "video:player_loc";
102 TagNames["video:content_loc"] = "video:content_loc";
103 TagNames["image:image"] = "image:image";
104 TagNames["image:loc"] = "image:loc";
105 TagNames["image:geo_location"] = "image:geo_location";
106 TagNames["image:license"] = "image:license";
107 TagNames["image:title"] = "image:title";
108 TagNames["image:caption"] = "image:caption";
109 TagNames["video:requires_subscription"] = "video:requires_subscription";
110 TagNames["video:publication_date"] = "video:publication_date";
111 TagNames["video:id"] = "video:id";
112 TagNames["video:restriction"] = "video:restriction";
113 TagNames["video:family_friendly"] = "video:family_friendly";
114 TagNames["video:view_count"] = "video:view_count";
115 TagNames["video:uploader"] = "video:uploader";
116 TagNames["video:expiration_date"] = "video:expiration_date";
117 TagNames["video:platform"] = "video:platform";
118 TagNames["video:price"] = "video:price";
119 TagNames["video:rating"] = "video:rating";
120 TagNames["video:category"] = "video:category";
121 TagNames["video:live"] = "video:live";
122 TagNames["video:gallery_loc"] = "video:gallery_loc";
123 TagNames["news:news"] = "news:news";
124 TagNames["news:publication"] = "news:publication";
125 TagNames["news:name"] = "news:name";
126 TagNames["news:access"] = "news:access";
127 TagNames["news:genres"] = "news:genres";
128 TagNames["news:publication_date"] = "news:publication_date";
129 TagNames["news:title"] = "news:title";
130 TagNames["news:keywords"] = "news:keywords";
131 TagNames["news:stock_tickers"] = "news:stock_tickers";
132 TagNames["news:language"] = "news:language";
133 TagNames["mobile:mobile"] = "mobile:mobile";
134 TagNames["xhtml:link"] = "xhtml:link";
135 TagNames["expires"] = "expires";
136})(TagNames = exports.TagNames || (exports.TagNames = {}));