Update Site source
This commit is contained in:
1 parent
d34e9e3901
commit
2a1cb909b4
5 files changed
+42
-9
No files matched your search
@@ -0,0 +1,13 @@
|
||||
// Apply the same Unix timestamp to both the shared page and its preview image.
|
||||
export function shareTimestamp(value) {
|
||||
if(typeof value!=='string'||!/^\d{1,12}$/.test(value))return null;
|
||||
const number=Number(value);
|
||||
return Number.isSafeInteger(number)&&number>=0?String(number):null;
|
||||
}
|
||||
export function withShareTimestamp(url,seconds) {
|
||||
const timestamp=shareTimestamp(String(seconds));
|
||||
if(timestamp===null)throw new Error('زمان اشتراک معتبر نیست.');
|
||||
const result=new URL(url);
|
||||
result.searchParams.set('t',timestamp);
|
||||
return result.href;
|
||||
}
|
||||
Reference in new issue
Block a user