I have the following url and a parameter :
number:200
"http://localhost:8000/textpath"
I want the path to be like this:
"http://localhost:8000/textpath/200"
How do I do that using Reactjs?I want to use the appended url in fetch method as follows:
fetch("http://localhost:8000/textpath/200")
A simple append did the work.Doesn't have to complicate
fetch("http://localhost:8000/textpath/"+number)
Try using Template literals.
const url = `http://localhost:8000/textpath/${number}`
fetch(url);
where number = 200
Refer here for more information
I have a whois form that works with get query string and make results.
I want to redirect url from:
mysite.com/domain/google.com
to
mysite.com/domain?sld=google&tld=com
Thanks
In .htacees
For example try this --
Redirect /domain/google.com /domain?sld=google&tld=com
OR
Try this using through jquery for using any url
var baseurl = "mysite.com/domain/";
var a = window.location.pathname.split("/").pop();
var name = a.split(".")[0];
var name1 = a.split(".")[1];
alert(name);
alert(name1);
alert(baseurl+'?sld='+name+'&tld='+name1);
window.open(baseurl+'?sld='+name+'&tld='+name1);
Hope it will work for you
I want "value" from the following query string.
by doing request.query.filter i get the following
"[{\"property\":\"customerId\",\"value\":2,\"exactMatch\":true}]"
tried request.query.filter.value and request.query.filter["value"] but didn't work.
Request URL :
admin/api/login?action=get&_dc=1547652537836&filter=%5B%7B%22property%22%3A%22customerId%22%2C%22value%22%3A2%2C%22exactMatch%22%3Atrue%7D%5D
the query string seems to be a JSON string. so the first thing you have to do is convert it to json object to access it.
const query = "[{\"property\":\"customerId\",\"value\":2,\"exactMatch\":true}]";
const json = JSON.parse(query);
now you can access it with
json[0].value
How can I get this URL:
http://api.flickr.com/services/rest/?method=flickr.auth.getFrob&format=rest&api_key=xxx&perms=write&api_sig=xxx
Into:
http://api.flickr.com/services/auth/?api_key=xxx&perms=write&frob=xxx&api_sig=xxx
The frob parameter I have extracted from XML and stored in a string, so it looks like
String frob;
String originalURL;
//just need to join frob as well remove and rearrange accordingly
Try this:
var orgURL:String="http://api.flickr.com/services/rest/?method=flickr.auth.getFrob&format=rest&api_key=xxx&perms=write&api_sig=xxx";
var index:int = orgURL.indexOf("api_key");
var newURL:String="http://api.flickr.com/services/auth/?"+orgURL.substr(index)+"&frob=xxx";
or even simpler:
var orgURL:String="http://api.flickr.com/services/rest/?method=flickr.auth.getFrob&format=rest&api_key=xxx&perms=write&api_sig=xxx";
var newURL:String="http://api.flickr.com/services/auth/?"+orgURL.substr(orgURL.indexOf("api_key"))+"&frob=xxx";
Probably there is a method of doing this with regex, but this one is easier to understand :)
I am working on SharePoint 2010.I have an documentlibrary ID and document ID in that library with me.i don't have either web,site in which the document library is present.So now I have to get the Full URL of the document at runtime.How can I get it .
I have tried the following.
string filepath = currentList.DefaultViewUrl + "/" + sListItem.Url;
Please answer this.
Use the field "EncodedAbsUrl" on the SPListItem. Works for SPFile as well:
SPListItem item = ...;
string absUrl = (string) item[SPBuiltInFieldId.EncodedAbsUrl];
or for a SPFile
SPFile file = ...;
string absUrl = (string) file.Item[SPBuiltInFieldId.EncodedAbsUrl];
The built in field id is for sure the best way to go but it returns the Url as encoded which may or may not be what you want.
I think the best way is to add a little extension method to a utilities class somewhere:
public static string AbsoluteUrl(this SPFile File, bool Decode = true)
{
string EncodedUrl = File.Item[SPBuiltInFieldId.EncodedAbsUrl].ToString();
if (Decode)
return SPEncode.UrlDecodeAsUrl(EncodedUrl);
else
return EncodedUrl;
}
And then call as follows
Item.File.AbsoluteUrl();
if you want a decoded Url or
Item.File.AbsoluteUrl(false);
if you want the Url to remain encoded.
Note that the default parameter value for Decode will only be available in .Net4+ and therefore SP2013 only but you can easily create an overload method for SP2010. You'll also need a reference to Microsoft.SharePoint.Utilities namespace to access the SPEncode class.
Try this ,
using (SPSite ospSite = new SPSite("http://abcd:24931"))
{
using (SPWeb web = ospSite.OpenWeb("/subsite")
{
// Get document library collection here and fetch all the document urls
SPDocumentLibrary docLib = (SPDocumentLibrary)web.Lists["docu"];
//where docu is my document library
SPListItemCollection items = docLib.Items;
foreach (SPListItem item in items)
{
string url = item.Url;
}
}
}
Hope this shall get you going.
public string GetItemURL(SPListItem item)
{
string web = item.Web.Url;
string listID = item.ParentList.ID.ToString();
string contentType = item.ContentTypeId.ToString();
string itemID = item.ID.ToString();
string url = web+"/_layouts/listform.aspx?PageType=4&ListID={"+listID+"}&ID="+itemID+"&ContentTypeID="+contentType;
return url;
}
It's Working for me. Hope I help (List Item url)
If this is for the document library, try this one.
item.Web.Url+"/"+item.File.Url
Use below code to get absolute URL of file:
SPFile file;
string url = file.Item[SPBuiltInFieldId.EncodedAbsUrl] as string;
For what it's worth, accessing the item.Web property means you are actually instantiating the SPWeb object which means that this should be disposed otherwise you'll be causing memory leakage.
It's a lot of overhead when there are better and quicker ways already mentioned.
I would use the BuiltInFieldId.EncodedAbsUrl approach mentioned since this gives you the easiest access to what you want.
The answer is
string url = currentweb.url+"/"+ Listitem.url;