Redirect to target's location
This commit is contained in:
@ -1,3 +1,20 @@
|
||||
export const getLocationOfTarget = (target: string) => {
|
||||
return `Location of ${target}`;
|
||||
import axios from 'axios';
|
||||
|
||||
const fetchTarget = async (target: string) => {
|
||||
return await axios.get(target, {
|
||||
maxRedirects: 0,
|
||||
validateStatus: (status) => {
|
||||
return status >= 300 && status < 400;
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const getLocationOfTarget = async (target: string) => {
|
||||
try {
|
||||
const { headers } = await fetchTarget(target);
|
||||
return headers.location as string;
|
||||
}
|
||||
catch (err) {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user