www.js 1.66 KB
/**
 * Created by TaoHuang on 2017/2/22.
 */

'use strict';

const _ = require('lodash');

const helpers = global.yoho.helpers;
const TYPE = require('../type');

module.exports = [
    // 商品详情页老链接
    {
        type: TYPE.redirect,
        origin: /^\/product\/pro_([\d]+)_([\d]+)\/(.*).html(.*)/,
        target: (req, match, p1, p2, p3, p4) => helpers.urlFormat(`/p${p1}.html${p4}`, null, 'item')
    },

    {
        type: TYPE.redirect,
        origin: /^\/product\/pro_([\d]+)(.*)/,
        target: (req, match, p1) => helpers.urlFormat(`/p${p1}.html`, null, 'item')
    },

    // 商品详情页新链接
    {
        type: TYPE.redirect,
        origin: /\/p([\d]+)(.*)/,
        target: req => helpers.urlFormat(req.url, null, 'item')
    },

    {
        type: TYPE.redirect,
        origin: '/brands?gender=1,3&channel=boys',
        target: 'http://www.yohobuy.com/boys-brands/'
    },

    {
        type: TYPE.redirect,
        origin: '/brands?gender=2,3&channel=girls',
        target: 'http://www.yohobuy.com/girls-brands/'
    },

    {
        type: TYPE.redirect,
        origin: '/brands?msort=365&channel=kids',
        target: 'http://www.yohobuy.com/kids-brands/'
    },

    {
        type: TYPE.redirect,
        origin: '/brands?channel=lifestyle',
        target: 'http://www.yohobuy.com/lifestyle-brands/'
    },

    {
        type: TYPE.redirect,
        origin: (req) => req.path === '/brands/plusstar',
        target: (req) => {
            return helpers.urlFormat(
                `/${req.query.channel}-brands/plusstar/id${req.query.id || 0}-p${req.query.page || 1}/`,
                null,
                'www'
            );
        }
    }
];