Skip to content

Commit

Permalink
fix(RichUrl): transform 应有 reject
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Sep 15, 2022
1 parent d53844c commit 7bf2425
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/RichUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,25 @@ export class RichUrl {
data: TData,
) => Promise<string>,
): Promise<TData> {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
if (Array.isArray(data)) {
Promise.all(
(data as any[]).map((value, index) => {
return RichUrl.transform(value, callback).then(res => {
;(data as any[])[index] = res
})
}),
).then(() => resolve(data))
).then(() => resolve(data), reject)
} else if (isPlainObject(data)) {
Promise.all(
Object.keys(data).map(key => {
return RichUrl.transform((data as any)[key], callback).then(res => {
;(data as any)[key] = res
})
}),
).then(() => resolve(data))
).then(() => resolve(data), reject)
} else if (RichUrl.check(data)) {
callback(RichUrl.parse(data), data).then(resolve as any)
callback(RichUrl.parse(data), data).then(resolve as any, reject)
} else {
resolve(data)
}
Expand Down

0 comments on commit 7bf2425

Please sign in to comment.