New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mdpress/shared-utils

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mdpress/shared-utils - npm Package Compare versions

Comparing version

to
1.0.0-rc.12

24

lib/getPermalink.js

@@ -10,2 +10,24 @@ "use strict";

}
function toUtcTime(date) {
let year = 1970;
let month = 0;
let day = 1;
if (typeof date === 'string') {
const [yearStr, monthStr, dayStr] = date.split('-');
year = parseInt(yearStr, 10);
month = parseInt(monthStr, 10) - 1;
day = parseInt(dayStr, 10);
}
else if (date instanceof Date) {
// If `date` is an instance of Date,
// it's because it was parsed from the frontmatter
// by js-yaml, which always assumes UTC
return date.getTime();
}
return Date.UTC(year, month, day);
}
function addTzOffset(utc) {
const utcDate = new Date(utc);
return new Date(utc + utcDate.getTimezoneOffset() * 60 * 1000);
}
module.exports = function getPermalink({ pattern, slug, date, regularPath, localePath = '/' }) {

@@ -16,3 +38,3 @@ if (!pattern) {

slug = encodeURI(slug);
const d = new Date(date);
const d = addTzOffset(toUtcTime(date));
const year = d.getFullYear();

@@ -19,0 +41,0 @@ const iMonth = d.getMonth() + 1;

6

lib/inferTitle.js

@@ -7,8 +7,8 @@ "use strict";

module.exports = function (frontmatter, strippedContent) {
if (frontmatter.title) {
return deeplyParseHeaders_1.default(frontmatter.title);
}
if (frontmatter.home) {
return 'Home';
}
if (frontmatter.title) {
return deeplyParseHeaders_1.default(frontmatter.title);
}
const match = strippedContent.trim().match(/^#+\s+(.*)/);

@@ -15,0 +15,0 @@ if (match) {

"use strict";
// string.js slugify drops non ascii chars so we have to
// use a custom implementation here
const diacritics_1 = require("diacritics");
// eslint-disable-next-line no-control-regex
const rControl = /[\u0000-\u001f]/g;
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’–—<>,.?/]+/g;
const rCombining = /[\u0300-\u036F]/g;
module.exports = function slugify(str) {
return diacritics_1.remove(str)
// Split accented characters into components
return str.normalize('NFKD')
// Remove accents
.replace(rCombining, '')
// Remove control characters

@@ -11,0 +14,0 @@ .replace(rControl, '')

{
"name": "@mdpress/shared-utils",
"version": "1.0.0-rc.11",
"version": "1.0.0-rc.12",
"description": "shared-utils for mdpress",

@@ -51,3 +51,3 @@ "keywords": [

},
"gitHead": "6d513a3662a06dbd24f011982aa00a2ed989ab03"
"gitHead": "7081a43dc3b47505148d837aa89c790c6da5ef37"
}

@@ -1,3 +0,3 @@

# @mdpress/shard-utils
# @mdpress/shared-utils
> shard-utils for MdPress