JSFiddle - React, Tailwind, and code Playground

by dshilkret

JavaScript

var FieldValuesAsText = {};  
FieldValuesAsText.FileLeafRef = "White Lies-Unfinished Business.mp4";
var file = FieldValuesAsText.FileLeafRef;
FieldValuesAsText.FileRef = "/sites/ServiceNowDev1/Dev1Lib1/INC0000002/White Lies-Unfinished Business.mp4";
var fileRef = FieldValuesAsText.FileRef;
var ext = file.substring(file.lastIndexOf(".") + 1);
console.log(ext);
var uri;

if (ext == "mp4"){
	console.log("It is an mp4");
  uri = "/_layouts/15/stream.aspx?id=" + encodeURIComponent(fileRef);
  console.log(url);
} else {
		console.log("It is not an mp4");
}

// The given URL
var url = "https://dtecho365.sharepoint.com/sites/ServiceNowDev1/_api/Web/Lists(guid'4c621a04-8fe0-4f50-a690-08ceb25b8513')/Items(16207)";

// Split the URL at the occurrence of '/_api'
var parts = url.split('/_api');

// The part before '/_api'
var baseUrl = parts[0];

// The part including and after '/_api'
var apiPath = '/_api' + parts[1];

console.log('Base URL:', baseUrl);
console.log('API Path:', apiPath);

console.log(baseUrl + uri)