www.js
6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/**
* Created by TaoHuang on 2017/2/22.
*/
'use strict';
// const _ = require('lodash');
const helpers = global.yoho.helpers;
const TYPE = require('../type');
const MOBILE_DOMAIN = '//guang.m.yohobuy.com';
module.exports = [
{
type: TYPE.redirect,
origin: /^\/product\/sale(\/|())\?channel=(.*)/,
target: (req) => {
let channel = req.query.channel || req.yoho.channel;
return helpers.urlFormat(`/${channel}-sale/`);
}
},
{
type: TYPE.redirect,
origin: /^\/product\/(boys|girls|kids|lifestyle)-sale(.*)$/,
target: (req, match, channel, url) => {
return helpers.urlFormat(`/${channel}-sale${url}`);
}
},
{
type: TYPE.redirect,
origin: /^\/product\/sale\/(vip|breakingYards|newSale|discount)(.*)$/,
target: (req, match, type) => {
let channel = req.query.channel || req.yoho.channel;
if (type === 'discount') {
type += `/id${req.query.id}`;
}
return helpers.urlFormat(`/${channel}-sale/${type}`);
}
},
{
type: TYPE.redirect,
origin: '/product/sale/?msort=10',
target: helpers.urlFormat('/product/lifestyle-sale/')
},
// 商品详情页老链接,形试一
{
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\?.*channel=(boys|girls|kids|lifestyle)/,
target: (req) => {
return helpers.urlFormat(
`/${req.query.channel}-brands/`,
null,
'www'
);
}
},
// 品牌一览专题
{
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'
);
}
},
// 推荐词列表页
{
type: TYPE.rewrite,
origin: /^\/so\/(.*)\.html(.*)/,
target: (req, match, p1) => `/product/search/keyword/${p1}`
},
// 推荐词id列表页
{
type: TYPE.rewrite,
origin: /^\/chanpin\/(.*)\.html(.*)/,
target: (req, match, p1) => `/product/search/chanpin/${p1}`
},
// erp2good
{
type: TYPE.rewrite,
origin: (req) => {
return req.path === '/erp2goods';
},
target: '/common/erp2goods'
},
{
type: TYPE.redirect,
origin: '/index.html',
target: helpers.urlFormat('/')
},
// 新品到着
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-new/,
target: (req, match, channel) => {
req.pathChannel = channel;
return '/product/list/new';
}
},
// 逛
// 首页
{
type: TYPE.rewrite,
origin: /^\/guang\/(boys|girls|kids|lifestyle)(\/*)$/,
target: (req, match, channel) => {
req.query.channel = channel;
return `/guang/?chanel=${channel}`;
}
},
// 首页 + 类型
{
type: TYPE.rewrite,
origin: /^\/guang\/(boys|girls|kids|lifestyle)-t([\d]+)(\/*)$/,
target: (req, match, channel, type) => {
req.query.channel = channel;
req.query.type = type;
return `/guang/?chanel=${channel}&type=${type}`;
}
},
// 列表页 + 类型 + 翻页
{
type: TYPE.rewrite,
origin: /^\/guang\/(boys|girls|kids|lifestyle)-t([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, type, page) => {
req.query.channel = channel;
req.query.type = type;
req.query.page = page;
return `/guang/index/index/?type=${type}&channel=${page}`;
}
},
// 编缉首页
{
type: TYPE.rewrite,
origin: /^\/guang\/author-(boys|girls|kids|lifestyle)-([\d]+)(\/*)$/,
target: (req, match, channel, authorId) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}`;
}
},
// 编缉首页 + 翻页
{
type: TYPE.rewrite,
origin: /^\/guang\/author-(boys|girls|kids|lifestyle)-([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, authorId, page) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.query.page = page;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}-p${page}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}&page=${page}`;
}
},
// sale页
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-sale(.*)$/,
target: (req, match, channel, url) => {
req.query.channel = channel;
return `/product/sale${url}`;
}
},
{
type: TYPE.rewrite,
origin: /^\/shop([\d]+)-about/,
target: (req, match, id) => {
req.query.domain = req.subdomains[0];
req.query.shopId = id;
return '/product/index/about';
}
},
// {
// type: TYPE.rewrite,
// origin: /^\/(list|search|new|sale|shop)((\/|\?)(.*)|())$/,
// target: (req) => {
// return `/product${req.url}`;
// }
// },
];