Authored by yyq

url replace

@@ -15,10 +15,6 @@ const TYPE_LIST = [ @@ -15,10 +15,6 @@ const TYPE_LIST = [
15 ]; 15 ];
16 16
17 const tdk = { 17 const tdk = {
18 - _getDeaultList: async(ctx, next) => {  
19 -  
20 - },  
21 -  
22 // tdk 列表 18 // tdk 列表
23 index: async(ctx, next) => { 19 index: async(ctx, next) => {
24 let resData = {}; 20 let resData = {};
@@ -115,7 +111,12 @@ const tdk = { @@ -115,7 +111,12 @@ const tdk = {
115 return ctx.response.body = result; 111 return ctx.response.body = result;
116 } 112 }
117 113
118 - let hashKey = type === 'url' ? md5(key) : key; 114 + let hashKey = key;
  115 +
  116 + if (type === 'url') {
  117 + key = _.replace(key, /http[s]?:\/\//, '');
  118 + hashKey = md5(key);
  119 + }
119 120
120 await ctx.redis.multi([ 121 await ctx.redis.multi([
121 ['lpushx', `tdk:${type}:links`, hashKey], 122 ['lpushx', `tdk:${type}:links`, hashKey],
@@ -150,7 +151,12 @@ const tdk = { @@ -150,7 +151,12 @@ const tdk = {
150 return ctx.response.body = result; 151 return ctx.response.body = result;
151 } 152 }
152 153
153 - let hashKey = type === 'url' ? md5(key) : key; 154 + let hashKey = key;
  155 +
  156 + if (type === 'url') {
  157 + key = _.replace(key, /http[s]?:\/\//, '');
  158 + hashKey = md5(key);
  159 + }
154 160
155 await ctx.redis.multi([ 161 await ctx.redis.multi([
156 ['hmset', `tdk:${type}:${hashKey}`, 'title', title, 'keywords', keywords, 162 ['hmset', `tdk:${type}:${hashKey}`, 'title', title, 'keywords', keywords,
@@ -293,8 +293,6 @@ @@ -293,8 +293,6 @@
293 293
294 data = that.packReqData(); 294 data = that.packReqData();
295 295
296 - data.key = data.key.replace(/http[s]?:\/\//,'');  
297 -  
298 if (!data) { 296 if (!data) {
299 that.$errTip.text('请填写完整tdk信息'); 297 that.$errTip.text('请填写完整tdk信息');
300 return; 298 return;