Skip to content

Commit

Permalink
balh: fix releative url
Browse files Browse the repository at this point in the history
  • Loading branch information
ipcjs committed Jul 8, 2021
1 parent ffca9a1 commit 0ca6f11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/unblock-area-limit/src/api/bilibili.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class BiliBiliApi {
return Async.ajax<SeasonInfo>(`${this.server}/pgc/view/web/season?season_id=${season_id}`)
}
getSeasonInfoByEpSsIdOnBangumi(ep_id: string, season_id: string) {
return Async.ajax<SeasonInfoOnBangumi>('https://bangumi.bilibili.com/view/web_api/season?' + (ep_id != '' ? `ep_id=${ep_id}` : `season_id=${season_id}`))
return Async.ajax<SeasonInfoOnBangumi>('//bangumi.bilibili.com/view/web_api/season?' + (ep_id != '' ? `ep_id=${ep_id}` : `season_id=${season_id}`))
}
getSeasonInfoByEpSsIdOnThailand(ep_id: string, season_id: string) {
const params = '?' + (ep_id != '' ? `ep_id=${ep_id}` : `season_id=${season_id}`) + `&mobi_app=bstar_a&s_locale=zh_SG`
Expand Down
4 changes: 2 additions & 2 deletions packages/unblock-area-limit/src/util/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace Async {
req.withCredentials = true
let authorization = ''
// 理论上来说网页中的请求不应该带username&password, 这里直接将它们替换成authorization header...
const originUrl = new URL(url)
const originUrl = new URL(url, document.location.href)
if (originUrl.username && originUrl.password) {
authorization = "Basic " + btoa(`${originUrl.username}:${originUrl.password}`)
// 清除username&password
Expand All @@ -114,7 +114,7 @@ namespace Async {
const creator = () => new Promise<T>((resolve, reject) => {
let options: any = { url: url }

const originUrl = new URL(url)
const originUrl = new URL(url, document.location.href)
// 同上
if (originUrl.username && originUrl.password) {
options.headers = { 'Authorization': 'Basic ' + btoa(`${originUrl.username}:${originUrl.password}`) }
Expand Down

0 comments on commit 0ca6f11

Please sign in to comment.