I have a facebook like button, with layout button_count which works perfectly in most situations but when the URL being shared contains [] it is altering that part of the URL to be [0].
I see the same behaviour with the Open Graph Object Debugger. If I enter the URL http://example.com?test%5B%5D=1 it gets transformed to http://example.com/?test%5B0%5D=1 (note the zero that has crept in).
I have tried with the initial URL both escaped and un-escaped with the same results.
I have tried configuring the like button with an href attribute and a data-href attribute and setting the og:url manually all to have escaped and unescaped versions of the URL but it insists on adding the 0 between empty square brackets.
The application that is consuming the URL is a rails application which translates the request parameters to "test" => { "0" => "1" } whereas my application is expecting "test" => ["1"].
Any ideas how to get facebook to leave the URL as it is? (I really don't want to have to parse the parameters a different way just for facebook requests - other social media sharing options work okay and leave the URL alone).
Related
I'm trying to add param in the url, like in this example:
https://www.google.com/ > https://www.google.com/search?q=qq
Opening the last link you can see "qq" in the "q" input.
For this site it doesn't work (this is the problem):
https://www.calabriasue.it/assistenza/richiesta-assistenza-e-supporto/
https://www.calabriasue.it/assistenza/richiesta-assistenza-e-supporto/?nome=mario
Can I add url param also in the last one? I need it.
Thanks!
I tried using different input names, different params ecc but it doesn't work.
Google's server side code is designed to generate an HTML document with an input field that is prefilled with the current search term which is reads from the URL. That is why adding q=search+term to the URL populates the input field.
You can't make arbitrary third-party websites prefill inputs. They have to explicitly provide a mechanism to make it possible.
Parameters only work as long as the code for the target website is expecting to handle a parameter named "nome" with a value "mario". In the case of the google website, it is expecting a parameter named "q" and has a form input for it.
Clicking a URL sends a a GET request type, and the target site may only be accepting parameters from a POST request type. You could consider using the application known as "PostMan" to help with that.
Alternately, the target page you are viewing may be forwarded / routed from a different page which accepts parameters.
I wanted to redirect the user to the same url with double hashes in Ruby On Rails after saving info of that tab.
eg. www.mywebsite.com/user/index#profile#address
In this case, my profile tab has 4 sub tabs (one of them is address) each displayed in the url as second hash. All the four tabs have a common action and I want to redirect back to the same tab from which the user saved his last information. I wrote the following code in my user controller action
redirect_to :action => :index, :anchor => "profile#address"
But what it does is redirect to www.mywebsite.com/user/index#profile%23address and ultimately not opening the same tab where he was before saving the address info.(He is redirected to the first tab which I have set as default)
Please help me in this case.
A URL can only have a single fragment (the # part), so what you want to do is not possible and forbidden by e.g. RFC 3986. Rails follows that specification and "percent encodes" the second hash sign to keep the resulting URL standards conform.
You'll have to find a different way to encode the information (e.g. parsing the fragment with javascript).
Is that even a valid URL? I suspect that what rails is doing is correct in terms of whatever RFC governs what a valid url looks like.
If you really want to avoid the encoding of the second hash symbol, then you could try just adding a string to the end:
redirect_to "#{index_path}#profile#address"
However, this may have the same effect.
our front end guy needs to form a url containing the hash, (i.e, http://blah/#some-link.) when we hit this on the browser and inspect the http traffic using fiddler, we saw that everything after blah/ gets removed, so the request is really just http://blah/. we also confirmed this on our server eclipse debug log.
the request gets redirected to the correct login page by Spring security(because user hasn't logged in), but the url on the browser now shows:
http://blah/some-link (the hash got removed) but the url on the browser should really be http://blah/log-in.
any idea why this is? any fix or workaround? thanks in advance.
URI part after # is called a fragment:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
Scheme and hier-part identify the location of a document, and fragment helps the browser to identify a location inside this document.
Fragment is stripped from URI by client software before it is sent as a part of request.
From RFC3986:
the fragment identifier is not used in the scheme-specific
processing of a URI; instead, the fragment identifier is separated
from the rest of the URI prior to a dereference, and thus the
identifying information within the fragment itself is dereferenced
solely by the user agent, regardless of the URI scheme. Although
this separate handling is often perceived to be a loss of
information, particularly for accurate redirection of references as
resources move over time, it also serves to prevent information
providers from denying reference authors the right to refer to
information within a resource selectively.
Content after the # is only used on the client side, per HTTP specification. If you require that information on the server, you can either use a different separator, or you can submit it via ajax after the page has loaded by reading it on the client with javascript.
The part of the URI including and after the hash (#) is never sent to the server as part of the HTTP request.
The reason is that the hash identifier was originally designed to point at references within the given web page and not to new resources on the server.
If you want to get the hash identifier, you'll have to use some client-side JavaScript to grab the value and submit it with the form.
Hashmark is removed from URL when the back button is clicked in IE9, IE10 or IE11
In IE10 , first time on clicking the HREF link leads to the correct below url:
http://www.example.com/yy/zz/ff/paul.html#20007_14
If back button is clicked again the, then it comes to the below url:
http://www.example.com/yy/zz/ff/paul.html
Solution :
Please change the url with https
It works for me
you can do this with javascript
<script>
if(window.location.hash) {
console.log(window.location.hash);
window.location.hash = window.location.hash;
}
</script>
I have a user profile with an url field that shows their website. Right now it displays it like this: http://www.userwebsite.com
How can I remove the "http://www." part on my show.html.erb file, when displaying the user profile?
You can either play string games or you can use the URI module:
require 'uri'
url = URI.parse("http://www.userwebsite.com")
url.host.split(".")[-2..-1].join(".")
The advantage of doing it this way is that you know that you've only got the host at this point, not the scheme or any other noise, such as the post-host path, etc.
It's probably easier to just split the URL and do this stuff but you'll have more error handling and special case handling that way.
In order to maintain the current set of Urls in a project, I have to be able to use the # (pound sign) in the Url. For some reason the pound sign does not appear to work normally in this project for UrlMappings.groovy.
Is there a special escape-sequence that must be used when placing # signs in UrlMappings.groovy?
Am I missing some reason why one cannot use pound signs at all?
In the following URL Mapping example, the browser goes to the correct page, but the pageName variable is null:
"/test/${urlName}#/overview"(controller:'test', action:'overview') {
pageName = "overview"
}
I thought everything after # in the url would be treated on the client side of the browsers where it tries to find a and scroll to that location.
If you dump the request containing the pound char, do you even see the data behind #?
I used a Named URL mapping and it works fine, no need to escape the "#" sign:
name test: "/#abc" (controller: 'test', action:'homepage')
EDIT: My above answer is wrong. In fact, it falls to a special case when homepage is the default action of the view.
Netbrain is right, the path after "#" will never be sent to server. In stead, I found that it's possible using "%23" instead of "#". Please take a look at here.
For example, instead of /test#/abc we should use /test%23/abc as URL mapping (both at client side & server side).