Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hexo-abbrlink

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-abbrlink - npm Package Compare versions

Comparing version 2.0.2 to 2.0.4

lib/crc32.js

13

lib/logic.js
'use strict';
var crc = require('./crc16');
var crc16 = require('./crc16');
var crc32 = require('./crc32');
var model = require('./model');

@@ -13,4 +14,10 @@ var front = require('hexo-front-matter');

if (!abbrlink) {
let res = crc(data.title) >>> 0;
abbrlink = model.check(res);
var opt_alg = ((this.config.abbrlink && this.config.abbrlink.alg) ? this.config.abbrlink.alg : 'crc16');
var opt_rep = ((this.config.abbrlink && this.config.abbrlink.rep) ? this.config.abbrlink.rep : 'dec')
let res = (opt_alg == 'crc32' ? crc32.str(data.title) >>> 0 : crc16(data.title) >>> 0);
//check this abbrlink is already exist then get a different one
abbrlink = model.check(res);
//set abbrlink to hex or dec
abbrlink = opt_rep == 'hex' ? abbrlink.toString(16) : abbrlink;
data.abbrlink = abbrlink;

@@ -17,0 +24,0 @@ //re parse front matter

{
"name": "hexo-abbrlink",
"version": "2.0.2",
"version": "2.0.4",
"description": "create one and only link for every post for hexo",

@@ -5,0 +5,0 @@ "main": "index.js",

# hexo-abbrlink
A [Hexo plugin](https://hexo.io/plugins/) to generate static post link based on post title and time.
A [Hexo plugin](https://hexo.io/plugins/) to generate static post link based on post titles.

@@ -9,3 +9,3 @@ ## How to install

```
```
npm install hexo-abbrlink --save

@@ -20,15 +20,46 @@ ```

There are two settings:
```
alg -- Algorithm (currently support crc16 and crc32, which crc16 is default)
rep -- Represent (the generated link could be presented in hex or dec value)
```
```
# abbrlink config
abbrlink:
alg: crc32 #support crc16(default) and crc32
rep: hex #support dec(default) and hex
```
## Sample
The generated link will look like the following:
```
crc16 & hex
https://post.zz173.com/posts/66c8.html
crc16 & dec
https://post.zz173.com/posts/65535.html
```
```
crc32 & hex
https://post.zz173.com/posts/8ddf18fb.html
crc32 & dec
https://post.zz173.com/posts/1690090958.html
```
## Limitation
Maximum number of posts is 65535. (For a personal blog site, this number is decent)
Maximum number of posts is 65535 for crc16. (For a personal blog site, this number is decent)
## More info
## More info
see [this](https://post.zz173.com/detail/hexo-abbrlink.html)(Chinese)
## ThanksFor
[NoahDragon](https://github.com/NoahDragon)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc