Blame view

doraemon/middleware/htaccess/rules/list.js 4.63 KB
yyq authored
1 2 3 4 5 6
/**
 * Created by YanQing.Yang on 2017/3/9.
 */

'use strict';
yyq authored
7 8 9 10
// const _ = require('lodash');
// const helpers = global.yoho.helpers;

// const mapSort = require(`${global.utils}/map-sort`);
yyq authored
11 12 13
const TYPE = require('../type');

module.exports = [
yyq authored
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
    // TODO: 暂时注释,上线一段时间正常即可删除
    // // 老版newURL
    // {
    //     type: TYPE.redirect,
    //     origin: '/new?gender=1,3&order=s_t_desc&msort=1,3,4,6,7,8,308,360',
    //     target: helpers.urlFormat('/boys-new/', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/new?gender=2,3&order=s_t_desc&msort=1,3,4,6,7,8,308,360',
    //     target: helpers.urlFormat('/girls-new/', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/new?order=s_t_desc&msort=365',
    //     target: helpers.urlFormat('/kids-new/', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/new?order=s_t_desc&msort=10',
    //     target: helpers.urlFormat('/lifestyle-new/', null, 'list')
    // },
周少峰 authored
36
yyq authored
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
    // // 男生销售类目一级菜单
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=1,3&msort=1,3',
    //     target: helpers.urlFormat('/?category_id=5,8&gender=1,3', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=1,3&msort=6',
    //     target: helpers.urlFormat('/?category_id=11&gender=1,3', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=1,3&msort=7',
    //     target: helpers.urlFormat('/?category_id=14&gender=1,3', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=1,3&msort=8',
    //     target: helpers.urlFormat('/?category_id=17&gender=1,3', null, 'list')
    // },
周少峰 authored
58
yyq authored
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
    // // 女生销售类目一级菜单
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=2,3&msort=1,3',
    //     target: helpers.urlFormat('/?category_id=18,31,25&gender=2,3', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=2,3&msort=6',
    //     target: helpers.urlFormat('/?category_id=52&gender=2,3', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=2,3&msort=7',
    //     target: helpers.urlFormat('/?category_id=59&gender=2,3', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=2,3&msort=8,10,241',
    //     target: helpers.urlFormat('/?category_id=76&gender=2,3', null, 'list')
    // },
周少峰 authored
80
yyq authored
81 82 83 84 85 86
    // // 潮童销售类目一级菜单
    // {
    //     type: TYPE.redirect,
    //     origin: '/?gender=1,2,3&misort=382,368,372,448,392,388,384,414,429,390,425,464&msort=365',
    //     target: helpers.urlFormat('/?category_id=13,16,15&gender=1,2,3', null, 'list')
    // },
周少峰 authored
87
yyq authored
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    // // 创意生活销售类目一级菜单
    // {
    //     type: TYPE.redirect,
    //     origin: '/?msort=10&misort=103',
    //     target: helpers.urlFormat('/?category_id=21', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?msort=10&misort=266',
    //     target: helpers.urlFormat('/?category_id=20', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?msort=10&misort=101,280',
    //     target: helpers.urlFormat('/?category_id=251', null, 'list')
    // },
    // {
    //     type: TYPE.redirect,
    //     origin: '/?misort=259&msort=10',
    //     target: helpers.urlFormat('/?category_id=23', null, 'list')
    // },
yyq authored
109
yyq authored
110 111 112 113 114 115 116
    // // 筛选参数排序匹配
    // {
    //     type: TYPE.redirect,
    //     origin: req => {
    //         if (_.isEmpty(req.query)) {
    //             return false;
    //         }
yyq authored
117
yyq authored
118 119 120 121 122 123
    //         let sorts = mapSort(req.query);
    //         let queryKeys = _.keys(req.query);
    //         let index = 0;
    //         let matched = _.map(sorts, (val, key) => {
    //             return key === queryKeys[index++];
    //         });
yyq authored
124
yyq authored
125 126 127
    //         if (_.every(matched, match => match)) {
    //             return false;
    //         }
yyq authored
128
yyq authored
129 130 131 132
    //         return true;
    //     },
    //     target: req => helpers.urlFormat(req.path, mapSort(req.query), 'list')
    // },
yyq authored
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
    {
        type: TYPE.rewrite,
        origin: req => {
            return !req.path || req.path === '/';
        },
        target: '/product/list/index'
    },
    {
        type: TYPE.rewrite,
        origin: /\/(.*)-new/,
        target: (req, match, channel) => {
            return `/product/list/${channel}-new`;
        }
    },
    {
        type: TYPE.rewrite,
        origin: req => req.path === '/new',
        target: '/product/list/new'
    }
];