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 :)
Related
I get this URL https://www.ikinciyeni.com/giris?ReturnUrl=/konsinye-hesap-sonuc&tempId=8642aa95-ebf9-4d00-8fd5-6d6c2f6023b2 I want to be able to get everything after tempId including tempId. How do I do that?
I have tried this:
var pattern = "tempId=";
var str2 = response.url().substr(response.url().indexOf(pattern), pattern.length);
console.log(str2);
How do I get to the end of string rather than just pattern's length
You can use the URL class to parse the url string, and then access the search parameters by name, for example:
// Create URL object from URL string.
const myUrl = new URL('https://www.ikinciyeni.com/giris?ReturnUrl=/konsinye-hesap-sonuc&tempId=8642aa95-ebf9-4d00-8fd5-6d6c2f6023b2');
// Get tempId parameter
console.log("tempId:", myUrl.searchParams.get("tempId"));
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
Take a look in this call:
//http://myserver.com/products/list/categories/
//http://myserver.com/products/list/categories/shoes/
//http://myserver.com/products/list/categories/shoes/woman
//http://myserver.com/products/list/categories/shoes/woman/leather
It's like a webshop where you will have a root category and undefined number of categories
So, on my node.js code, I'd like to implement a sort of flexible number of categories and I don't know how to work in this way. Never did it before.
I've the sentence bellow, but this will allow me to work with a single argument.
app.get('/arg1:/products/list/categories/:argument', productsCategories.index);
I can do such things like place a very good amount of parameters such as:
app.get('/arg1:/products/list/categories/:par1:', productsCategories.index);
app.get('/arg1:/products/list/categories/:par1:/par2', productsCategories.index);
app.get('/arg1:/products/list/categories/:par1:/par2:/par3', productsCategories.index);
//...par4, par5,par6......par20
and mat to the same file and test the parameters. but I don't this that's the best way. Any clue ?
You could possibly use a regex to capture the routes and then split them.
app.get(/^\/(.+?)\/products\/list\/categories\/((?:[^\/]+\/?)+)/, function(req, res) {
// /test/products/list/categories/shoes/woman/leather would return [['test'],['shoes','woman','leather']]
var webShopId = req.params[0];
var categories = req.params[1].split('/');
});
Currently, I used MongoVUE to import from current SQL Server database but all PK with uniqueidentifier were converted to something like "Binary - 3:UuidLegacy
My question is how do is create schema for this structure on Mongoose? I can't see Guid/UUID datatype on Mongoose docs http://mongoosejs.com/docs/api.html#schema_Schema.Types
And for more, I get issue when query with ValidationID something like
db.Validations.find({ValidationID: '1389AB5E-56BD-46FD-9A8A-258C7BDE4251'});
It returns nothing although this Guid is exactly same with SQL Server record.
Thanks.
MongoVUE is obscuring things a bit here, but in a nice way that makes it easier to read. Here's what your example ValidationID of '1389AB5E-56BD-46FD-9A8A-258C7BDE4251' actually looks like - it's type 3 BinData:
{"ValidationID" : BinData(3,"E4mrXla9Rv2aiiWMe95CUQ==")}
The viewer is converting that to a more readable format for you. It's doing that by converting to hex and adding dashes. For proof:
> var bar = BinData(3,"E4mrXla9Rv2aiiWMe95CUQ==")
> bar.hex()
1389ab5e56bd46fd9a8a258c7bde4251
If you want to find that ID, then strip the dashes and pass that into the find as follows (I inserted a sample doc):
> db.foo.find({ValidationID: UUID('1389AB5E56BD46FD9A8A258C7BDE4251')})
{ "_id" : ObjectId("544fd7ddbb4f50c77c61f367"), "ValidationID" : BinData(3,"E4mrXla9Rv2aiiWMe95CUQ==") }
I don't have mongoose set up to test, but have done the leg work in another answer similar to this in terms of converting in javascript.
This drove me crazy for several hours, as a solution I ended up having to install
npm install mongodb --save
npm install slugid --save
and code it as follows
var mongo = require('mongodb');
var slugid = require('slugid');
...
var guidb64 = slugid.encode(guid); // guid is something like '8440d561-1127-4fd8-aca9-54de19465d0b'
guidb64 = guidb64.replace(/_/g, '/'); // for whatever reason slug uses '_' instead of '/' I have in db
guidb64 += '=='; // adding missing trailing '==' I have in db
var GUID = new mongo.Binary(new Buffer(guidb64, 'base64'), 3);
var query = MySchemaType.findOne({ Guid: GUID });
query.exec(function(err, entity) {
// process
})
How do you deal with the fact, that URLs are case sensitive in xPages even for parameters? For example URL:
my_page.xsp?folderid=785478 ... is not the same as ...
my_page.xsp?FOLDERID=785478
How to make, for example, a proper check that params contain some key e.g.
param.containsKey("folderid") which desnt work when there is 'FOLDERID' in URL.
I'd suggest defining a couple convenience #Functions:
var #HasParam = function(parameter) {
var result:boolean = false;
for (var eachParam : param.keySet()) {
if (eachParam.toLowerCase() == parameter.toLowerCase()) {
result = true;
break;
}
}
return result;
};
var #GetParam = function(parameter) {
var result = "";
if (#HasParam(parameter)) {
for (var eachParam : param.keySet()) {
if (eachParam.toLowerCase() == parameter.toLowerCase()) {
result = param.get(eachParam);
break;
}
}
}
return result;
};
Then you can safely query the parameters without caring about case. For bonus points, you could add requestScope caching so that you can skip looping through the keySet if you're examining a parameter that you've previously looked at during the same request.
you may use this function:
context.getUrlParameter('param_name')
then test if it's null or not.
make sure to decide for one,so either upper or lowercase
other than that i'd suggest something like
KeyValuePair<string,string> kvp = null;
foreach(KeyValuePair<string,string> p in param)
{
if(UPPERCASE(p.Key) == UPPERCASE("folderid"))
{
kvp = p;
break;
}
}
syntax isn't correct and idk the uppercase method in c# right now,but you get the point
The easiest answer is ofcourse the obvious. Be sure that the parameters you are using througout your application are always the same on every url you are generating and know what to expect. A good approach to accomplish this is to create a ssjs function which generates url's for you according to the objects you submit.
In this function you could check which object you are receiving and with the use of keywords and so forth generate the correct url. This way generating twice a url with the same input parameters should always generate the exact same url.
another option would be just to double check with a bit of code like this
var key = "yourkey";
if(param.contains(#uppercase(key)) || param.contains(#lowercase(key)){
// do stuff
}
But should not be necesarry if the url you are parsing is generated by your own application
Edit after post of topic starter
Another option would be to grap the url directly from from the facescontext and to convert it to a string first. When it is a string you can parse the parameters yourself.
You can combine server side substitution/redirection to get around the issue that David mentioned. So a substitution rule will redirect incoming patern like this:
http://myhost/mypage/param (/mypage/* => which converts to - /dbpath/mypage.xsp?*) - substitution is tricky so please handle with care.
Also I believe I read somewhere that context.getUrlParameter is not case sensitive - can someone please confirm this.
Hope this helps.