mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
feat: add common-utils (#2374)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const got = require('@/utils/got');
|
||||
const { toTitleCase } = require('@/utils/common-utils');
|
||||
const dayjs = require('dayjs');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
@@ -13,7 +14,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
locations.split(',').forEach(function(pair) {
|
||||
const country = pair.split('+')[0];
|
||||
const city = titleCase(pair.split('+')[1]);
|
||||
const city = toTitleCase(pair.split('+')[1]);
|
||||
url += `{"country":"${country}","city":"${city}"},`;
|
||||
|
||||
host += `/${country}/${city.replace(' ', '_')}`;
|
||||
@@ -43,12 +44,3 @@ module.exports = async (ctx) => {
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
||||
const titleCase = (str) =>
|
||||
str
|
||||
.toLowerCase()
|
||||
.split(' ')
|
||||
.map(function(word) {
|
||||
return word.replace(word[0], word[0].toUpperCase());
|
||||
})
|
||||
.join(' ');
|
||||
|
||||
Reference in New Issue
Block a user