* Public urls
(itemId, itemTitle = null, baseUrl = '/', locale = 'en')
| 248 | * Public urls |
| 249 | */ |
| 250 | function webItem(itemId, itemTitle = null, baseUrl = '/', locale = 'en') { |
| 251 | if (itemTitle) { |
| 252 | const title = truncateString(itemTitle, 50, false); |
| 253 | let slug = slugify(title, { |
| 254 | lower: true, |
| 255 | strict: true, // strip special characters except replacement |
| 256 | locale, |
| 257 | }); |
| 258 | // Fallback to a custom implementation to deal with all non-English characters. |
| 259 | if (!slug) { |
| 260 | slug = title |
| 261 | .toString() |
| 262 | .normalize('NFKD') |
| 263 | .toLowerCase() |
| 264 | .trim() |
| 265 | .replace(/['!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/g, '-') |
| 266 | .replace(/\s+/g, '-') |
| 267 | .replace(/\_/g, '-') |
| 268 | .replace(/\-\-+/g, '-') |
| 269 | .replace(/\-$/g, ''); |
| 270 | } |
| 271 | return urlJoin(baseUrl, `/i/${slug}-${itemId}/`); |
| 272 | } else { |
| 273 | return urlJoin(baseUrl, `/i/${itemId}/`); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | export const PUBLIC_URLS = { |
| 278 | webFeed: (baseUrl = '/') => { |
no test coverage detected