| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1x 7x 3x 1x 2x 1x 1x 3x 4x | const generateLink = (location, current, target, hostname) => {
if (location && hostname) {
let path;
if (current) {
path = location.pathname.replace(current, target);
} else if (target) {
path = `/${target}/`;
} else {
path = '/';
}
return `${location.protocol}//${hostname}${path}${location.search}${location.hash}`;
}
return '#';
};
export default generateLink;
|