feat: deeplink & vercel

This commit is contained in:
2025-11-04 17:08:59 +01:00
parent 673199ff87
commit ffaccd71a7
8 changed files with 246 additions and 16 deletions
+32 -8
View File
@@ -102,19 +102,42 @@ const UniversalLinkProvider = ({ children }) => {
}, [isFullyLoaded, pendingMusicId]);
const handleParams = (path, _queryParams = {}) => {
if (typeof path === "string" && path.length > 0) {
const normalized = path.replace(/^\/+/, "");
const [first, second] = normalized.split("/");
if (first?.toLowerCase() === "music" && second) {
if ((typeof path === "string" && path.length > 0) || _queryParams?.music) {
const normalized = typeof path === "string" ? path.replace(/^\/+/, "") : "";
const segments = normalized
.split("/")
.map((segment) => segment.trim())
.filter(Boolean);
const musicIndex = segments.findIndex(
(segment) => segment?.toLowerCase() === "music"
);
let musicIdentifier = null;
if (musicIndex !== -1 && segments[musicIndex + 1]) {
musicIdentifier = segments[musicIndex + 1];
} else if (segments.length === 1 && segments[0]) {
musicIdentifier = segments[0];
} else if (typeof _queryParams?.music === "string") {
musicIdentifier = _queryParams.music;
} else if (typeof _queryParams?.projectId === "string") {
musicIdentifier = _queryParams.projectId;
}
if (musicIdentifier) {
try {
setPendingMusicId(decodeURIComponent(second));
setPendingMusicId(decodeURIComponent(musicIdentifier));
} catch (_) {
setPendingMusicId(second);
setPendingMusicId(musicIdentifier);
}
}
}
cleanURL();
if (isWeb) {
setTimeout(cleanURL, 1500);
} else {
cleanURL();
}
};
const cleanURL = () => {
@@ -124,7 +147,8 @@ const UniversalLinkProvider = ({ children }) => {
// console.log(url);
url.search = "";
window.history.replaceState({}, document.title, url.origin.toString());
const next = `${url.origin}${url.pathname}${url.hash || ""}`;
window.history.replaceState({}, document.title, next);
}
};