url-parameters

How to extract parameters from a URL regardless the way it written by?

这一生的挚爱 提交于 2019-12-08 01:54:36
问题 I want a java way to extract the parameters of a URL regardless the way these parameters are written in it, in the regular way like( https://www.facebook.com/Doly.mohamed.Smile9?ref=stream&hc_location=stream ) it's so easy because all i have to do is : URL url = new URL("www.blabla....etc"); String query = url.getQuery(); try{ String [] params = query.split("&"); for(int i= 0 ; i < params.length; i++){ String [] split = params[i].split("="); parameters.put(split[0], split[1]); } }catch

window.location.hash issue in Firefox

£可爱£侵袭症+ 提交于 2019-12-07 05:21:16
问题 Consider the following code: hashString = window.location.hash.substring(1); alert('Hash String = '+hashString); When run with the following hash: #car=Town%20%26%20Country the result in Chrome and Safari will be: car=Town%20%26%20Country but in Firefox (Mac AND PC) will be: car=Town & Country Because I use the same code to parse query and hash params: function parseParams(paramString) { var params = {}; var e, a = /\+/g, // Regex for replacing addition symbol with a space r = /([^&;=]+)=?([^

How do you test the params hash in a Rails test?

风流意气都作罢 提交于 2019-12-07 02:34:01
问题 The following generates an error: "undefined local variable or method `params'" assert_equal params[:recipient_id], users(:one).id How do you test the params hash? Also, how do you test assert_redirect when there are params present? The params are appended to the URL, so testing for model_path or similar fails. Working with built in test class in Rails 3. 回答1: http://guides.rubyonrails.org/testing.html#functional-tests-for-your-controllers gives some of this information. In this case, params

How do you programmatically update URL params in react-router?

纵然是瞬间 提交于 2019-12-06 21:40:35
This answer doesn't quite cover it since it appears that you have to pass a reconstructed URL into pathname If I am on the child page of these routes: <Route name="Parent" path="/parent/:parentId" component={Parent}> <Route name="Child" path="/child/:childId" component={Child}> how do I programmatically update the :parentId without having to re-construct the entire URL? Something along the lines of history.push({ ...., params: {parentId: 'newParent'}}) would be ideal. Thanks! 来源: https://stackoverflow.com/questions/42729802/how-do-you-programmatically-update-url-params-in-react-router

Add a configurable product to the cart using url

我是研究僧i 提交于 2019-12-06 16:03:03
问题 I'm attempting to add a configurable product to the cart using the url parameters but I'm still getting a "Please specify the product's option(s)." when I try to add a product to the cart using the url: /myConfigurableProduct.html?options=cart&product=6&related_product=&super_attribute[146]=60&super_attribute[147]=67&super_attribute[145]=57&super_attribute[144]=49&super_attribute[148]=69&super_attribute[149]=75&super_attribute[150]=80&qty=1 I've looked through the Magento docs for a solution

The torrent info_hash parameter

点点圈 提交于 2019-12-06 04:42:04
问题 How does one calculate the info_hash parameter ? Aka the hash corresponding to the info dictionar?? From official specs: info_hash The 20 byte sha1 hash of the bencoded form of the info value from the metainfo file. Note that this is a substring of the metainfo file. This value will almost certainly have to be escaped. Does this mean simply get the substring from the meta-info file and do a sha-1 hash on the reprezentative bytes?? .... because this is how i tried 12 times but without succes

Getting more search results per page via URL

北城以北 提交于 2019-12-05 23:18:17
问题 I've been writing a program which extracts data from web searches. To get more data, I'd ideally like to extract more results per query through a script (let's say 100 or so). My question is, is there a way to modify the URL for Google, Yahoo, or Bing (preference in that order) so that I can get more than 10 results per query? For Google, appending &num=99 used to work at one point but no longer works :( I saw a similar append of &count=50 but that didn't work on any of the search engines

jquery mobile url parameter not updating in browser, but getting correct one with “data-url”

血红的双手。 提交于 2019-12-05 17:55:06
I created the following example to show what I am experiencing. If I navigate from page1 to page 2 with the button Page 2a, the URL will be ...#page2?id=a as expected. When I click the button to go back to Page 1, then navigate to Page 2b, the URL will still show "#page2?id= a ", but the <a> tag is clearly has an href of "#page2?id= b " along with the $(e.target).attr("data-url") being "#page2?id= b " when I get to #page2. Any ideas what is going on here? Thanks in advance for any help. <html> <head> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css"

Is it secure to put the user id as a url parameter?

大憨熊 提交于 2019-12-05 16:08:05
I am developing a social network and I would like to know if in the profile page of a user I could put the user id stored in database as a parameter in the url or is it a bad idea in terms of security? I want the url to be bookmarkable. Should I put another thing instead of the user id? Darin Dimitrov In terms of security there's no problem in putting the user id in a url. For example StackOverflow does it already: https://stackoverflow.com/users/3477044/aliuk What's important is to verify that the currently authenticated user is allowed to access this url and take actions on its behalf. most

window.location.hash issue in Firefox

六眼飞鱼酱① 提交于 2019-12-05 10:24:47
Consider the following code: hashString = window.location.hash.substring(1); alert('Hash String = '+hashString); When run with the following hash: #car=Town%20%26%20Country the result in Chrome and Safari will be: car=Town%20%26%20Country but in Firefox (Mac AND PC) will be: car=Town & Country Because I use the same code to parse query and hash params: function parseParams(paramString) { var params = {}; var e, a = /\+/g, // Regex for replacing addition symbol with a space r = /([^&;=]+)=?([^&;]*)/g, d = function (s) { return decodeURIComponent(s.replace(a, " ")); }, q = paramString; while (e