www.js
6.92 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
/**
* 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, match, channel) => {
return helpers.urlFormat(`/product/${channel}-sale/`);
}
},
{
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}`
},
// TODO
// {
// type: TYPE.redirect,
// origin: /^\/so\/(.*)\.html(.*)/,
// target: (req, match, p1) => {
// let urls = {
// '4175746F426F74E6898BE69CBAE9858DE4BBB6E794B7': 57517,
// E6BBA1E58DB0E4BABAE5AD97E68B96: 11877,
// E6BDAEE6ACBEE5A4AAE79CBCE9959C: 43319,
// E6B3A2E782B9E995BFE8A296E8A1ACE8A1A3: 5709,
// E688B7E5A496E58C85E9858D: 27481,
// E993B6E98791E889B2: 12279,
// E697B6E5B09AE68ABDE7BBB3E79FADE8A3A4: 84593,
// '4C554E414C494D49544544E99288E7BB87E5A5B3': 36255,
// '4B4F594F': 10297,
// E99288E7BB87E8A5BFE8A385: 72093,
// E8838CE5BF83E995BFE8A399: 81419,
// E9929FE8A1A8E5A5B3: 71361,
// '424142414D41E79AAEE5B8A6': 47883,
// E5BEBDE7ABA0E58DABE8A1A3: 75023,
// E9BB91E799BDE6A0BC: 20095,
// E7949CE7BE8EE7BAAFE889B2E79FADE8A3A4: 10309,
// E58DB0E88AB1E995BFE6ACBEE7BEBDE7BB92E69C8D: 62085,
// E68B89E993BEE5BC80E8A59F: 43223,
// E7BBBFE889B2E7AE80E7BAA6E4BC91E997B2E8A3A4: 7781,
// E79CBCE5BDB1E5A5B3: 39279,
// E7BAAFE889B2E6A392E79083E5B8BD: 2021,
// E5A191E69699E590B8E7AEA1E69DAF: 1956427,
// E59BB4E5859C20E794B7: 71493,
// E59BB4E5859C20E5A5B3: 65257,
// E68BBCE889B2E6898BE993BE: 48821,
// '5452494E49544573747564696FE8A1ACE8A1AB': 53871,
// E799BDE889B2E9A490E585B7: 36291,
// E8939DE889B2E79CBCE9959C: 6287,
// E7AB96E69DA1E7BAB9E8BF9EE8A1A3E8A399: 40513,
// E7899BE4BB94E8939DE794B7E5A3ABE995BFE8A3A4: 2297,
// E58DB0E88AB1E4BC91E997B2E5A4B9E5858B: 26725,
// E8BF90E58AA8E8939DE78999E880B3E69CBA: 46837,
// E7BAAFE889B2E6B299E6BBA9E8A3A4: 8709,
// E7BAAFE889B2E8B4B4E6A087: 28027
// };
//
// return urls[p1] ?
// helpers.urlFormat(`/chanpin/${urls[p1]}.html`, null, 'www') :
// helpers.urlFormat('/', null, 'www');
// }
// },
// 推荐词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: /^\/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}`;
}
},
{
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';
}
}
];