81 lines
2.2 KiB
HTML
81 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>SharePoint Link Encoder</title>
|
|
<style>
|
|
body { font-family: sans-serif; margin: 2rem; }
|
|
input[type=text] { width: 100%; padding: 0.5rem; height: 400px; width: 800px;}
|
|
button { margin-top: 1rem; padding: 0.5rem 1rem; }
|
|
pre { background: #f4f4f4; padding: 1rem; white-space: pre-wrap; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>SharePoint Link Encoder</h1>
|
|
<p>Paste your SharePoint/OneDrive link below and click Encode.</p>
|
|
<form id="encoderForm">
|
|
<input type="text" id="urlInput" placeholder="https://..." />
|
|
<button type="submit">Encode</button>
|
|
</form>
|
|
|
|
<div id="results"></div>
|
|
|
|
<script>
|
|
function encodeShareLink(url) {
|
|
const step0 = url
|
|
const step1 = btoa(unescape(encodeURIComponent(step0))) // UTF-8 → Base64
|
|
const step2 = step1.replace(/\//g, '_')
|
|
const step3 = step2.replace(/\+/g, '-')
|
|
const step4 = step3.replace(/=+$/g, '')
|
|
const step5 = 'u!' + step4
|
|
const endpoint = 'https://graph.microsoft.com/v1.0/shares/' + step5 + '/driveItem'
|
|
|
|
return { step0, step1, step2, step3, step4, step5, endpoint }
|
|
}
|
|
|
|
document.getElementById('encoderForm').addEventListener('submit', function(e) {
|
|
e.preventDefault()
|
|
const url = document.getElementById('urlInput').value.trim()
|
|
if (!url) return
|
|
|
|
const result = encodeShareLink(url)
|
|
|
|
const output = `
|
|
Step 0 — Original URL:
|
|
${result.step0}
|
|
|
|
Step 1 — Base64:
|
|
${result.step1}
|
|
|
|
Step 2 — "/" → "_":
|
|
${result.step2}
|
|
|
|
Step 3 — "+" → "-":
|
|
${result.step3}
|
|
|
|
Step 4 — Trim "=":
|
|
${result.step4}
|
|
|
|
Step 5 — Add "u!":
|
|
${result.step5}
|
|
|
|
Step 6 — Graph endpoint:
|
|
${result.endpoint}
|
|
`
|
|
document.getElementById('results').innerHTML = '<h2>Encoding Steps</h2><pre>' + output + '</pre>'
|
|
})
|
|
</script>
|
|
<br>
|
|
<br>
|
|
From Graph return you will get JSON with "id" and "driveId" under parentReference.
|
|
id and driveId are the correct values.
|
|
<br>
|
|
Join them as /drives/{driveId}/items/{id} for use in app graph document manipulation
|
|
<br>
|
|
<form id="freeForm">
|
|
<br>
|
|
<input type="text" id="joinText" placeholder="Type or Paste stuff here." />
|
|
</form>
|
|
</body>
|
|
</html>
|