Avoid prepending home page to URLs? - jquery-terminal

I'm having some trouble figuring out how to resolve this issue I'm having with URLs.
Within one of my commands, I'm trying to link to outside sites by doing the following:
this.echo('' + contact[i] + '', {raw: true});
Where philip.contact[contact[0]] is the string "https://medium.com/". I get the following URL from the jquery terminal:
http://philipyoo.github.io/[[!;;]https://medium.com/]
Or I tried the following:
this.echo('' + mylink + '', {raw: true});
And get the following:
http://philipyoo.github.io/https://www.google.com]/
No [[!;;] in the url.
I saw the following closed issue for formatting multiple param urls, but I don't really follow the conversation. I'm not formatting my URLs in any way, but I get situations where I'll get the [[!;;] inserted into my URLs.
Any help is much appreciated!

Related

Cypress test passes single form input field but ignores the following one(s)

I’m trying to test a Stripe form with 3 input fields in Cypress. I found an example that works to test a single input that takes all the payment info (https://medium.com/#chipomapondera/hi-michael-98e432948028).
My version passes on inputting the CC but fails on the next input(s). My code is below:
it('checks user can support the Creator', () => {
cy.get('button[class="buttons__FollowButton-sc-10ti9z2-0 huoUmA"]').click()
cy.wait(4000)
cy.get('body')
.should('contain', 'Join this community')
cy.get('button[class="styledComponents__SubscribeButton-g42pit-3 kUgWbq"]').click()
cy.getWithinIframe('[name="cardnumber"]').type('4242424242424242')
.getWithinIframe('[name="exp-date"]').type('1232')
.getWithinIframe('[name="cvc"]').type('987')
})
It doesn’t seem to like the following after it has typed the card number:
cy.getWithinIframe(‘[name=”exp-date”]’).type(‘1232’)
cy.getWithinIframe(‘[name=”cvc”]’).type(‘987’)
The error I receive is:
cypress error
I could see a typo in the type field where there are no ending single quotes at this line of test .getWithinIframe('[name="exp-date"]').type('1232). Could you please try following .getWithinIframe('[name="exp-date"]').type('1232') or may be try without quotes .getWithinIframe('[name="exp-date"]').type(1232)
I followed the medium article you shared and ran into the same issue as you. The cause of this problem is of course that stripe is creating multiple iframes and the method created in the article is just getting the first iframe.
So a very simple solution is to pass the id of the div containing the iframe to our getWithinIframe function. The function will now look like this:
Cypress.Commands.add('getWithinIframe', (iframeSelector, targetElement) =>
cy.get(`#${iframeSelector} iframe`).iframeLoaded().its('document').getInDocument(targetElement));
And call it like so:
cy.getWithinIframe('cardNumberElement','[name="cardnumber"]').type(1212123);
Hope this helps anybody who is facing the same issues.

URI::InvalidURIError while trying to download by URL with square brackets

I am currently trying to download the picture of this link:
http://z.mfcdn.net/store/manga/9/14-116.0/compressed/Bleach-14-116[manga-rain]._manga_rain_bleach_ch116_01.jpg
This generates a URI::InvalidURIError exception.
After reading around on Stack Overflow, I've tried ( but failed ):
uri = URI.parse(URI.encode(url.strip))
safeurl = URI.encode(url.strip)
I do know the issue has something to do with web browsers being more "friendly" but I do not know how to get my application to do the same.
Here's a sort of hack way of dealing with the invalid characters in the URL:
u = 'http://z.mfcdn.net/store/manga/9/14-116.0/compressed/Bleach-14-116[manga-rain]._manga_rain_bleach_ch116_01.jpg'
fixed = u.gsub(/[\[\]]/) { '%%%s' % $&.ord.to_s(16) }
open(fixed)
That should deal with this particular problem.

Ajax request POST returns 403 error, GET returns 200 ok on same url

I'm trying to set up a prestashop webshop and I bought a theme to customize it. Instalation works great, but when reaching the live edit module of the theme I ran into a problem: after customizing the layout I tried to save my modifications, but it returns with 403 error. I've tried to debug it, I've contacted my hosting, I've contacted the developer of the theme, but noone can help me. In the error logs doesn't appear anything regarding this issue. The developer says it is tested on multiple hosts, and it works great. My host says they can't do anything if there is no error message in the logs.
I've managed to circle down the issue a little bit. There is a larger sized parameter(it contains all new configurations) which if I disable to be sent, then I get the following error: "Your hosting provider has set a non-standard or too little value of parameter LimitRequestLine in httpd.conf. Set the default setting value of parameter LimitRequestLine in httpd.conf, please." This error I receive on post and get aswell.
This parameter can be the source of my problem if the http call is through ajax post? Or there is more this issue?
I'm trying to solve this issue for 3 months now, I've spoken to the hosting firm, I've spoken to the developer of the them, I've searched a lot of forums but found no answer to this. I'm desperate to get any help on this matter.
It looks like I solved the issue with the following codes:
/public_html/modules/ixtengine/js/cpanel/cpanel.min.js
... ,$.ajax({type:"POST",url:cpfuncurl+previewfun,data:{ ...
replaced by
... ,$.ajax({type:"PUT",url:cpfuncurl+previewfun,data:{ ...
and
... ,$.ajax({type:"POST",url:cpfuncurl+savefun,data:{ ...
replaced by
... ,$.ajax({type:"PUT",url:cpfuncurl+savefun,data:{ ...
/public_html/modules/ixtengine/cpanel/functions/upload.savepf.php and /public_html/modules/ixtengine/cpanel/functions/upload.previewwid.php
...
$theme = Tools::getValue('theme');
$conf = Tools::getValue('conf');
$skin = Tools::getValue('skin');
$skinid = Tools::getValue('skinid');
$token = Tools::getValue('token');
...
replaced by
...
$put_vars=array();
if($_SERVER['REQUEST_METHOD'] == 'PUT')
{
parse_str(file_get_contents("php://input"),$put_vars);
$theme = $put_vars['theme'];
$conf = $put_vars['conf'];
$skin = $put_vars['skin'];
$skinid = $put_vars['skinid'];
$token = $put_vars['token'];
}
else
{
$theme = Tools::getValue('theme');
$conf = Tools::getValue('conf');
$skin = Tools::getValue('skin');
$skinid = Tools::getValue('skinid');
$token = Tools::getValue('token');
}
...
This solution is particulary for the ixtengine module for some hosts where POST returns 403 error so I can't be sure if this method will work for someone else running into this problem, but it works for me.

Client-side translation does not work in CKAN

I am having issues with translating client-side text in CKAN. My site is in french, so here is the problem:
- if I click on the green button "S'abonner" from the left, it should change the button to a red one and show the text "Se désabonner", but instead, it shows me "Unfollow", like in the photos:
And if I click it again it shows me "Follow" (instead of "S'abonner"). So this is a problem on the client side. Normally, when you generate text on the server side you write in the templates _('msgid present in pofile'), but, on the client side, it uses the result from the AJAX call to "/api/i18n/{language}".
I did some digging and it seems that the client-side translation uses the result from the AJAX call to "/api/i18n/fr", but all I get is a json object:
{
"": {
"domain": "ckan",
"lang": "fr",
"plural-forms": "nplurals=2; plural=(n > 1)"
}
}
But, if I look at the ckan demo website, (http://demo.ckan.org/api/i18n/fr), I get a long JSON file, that contains all the translations.
I managed to discover from where this Ajax call is done, apparently it comes from : "src/ckan/ckan/public/base/javascript/client.js", at the function:
getLocaleData: function (locale, success, error) {
var url = this.url('/api/i18n/' + (locale || ''));
return jQuery.getJSON(url).then(success, error);
}
If I replace
var url = this.url('/api/i18n/' + (locale || ''));
with
var url = this.url('http://demo.ckan.org/api/i18n/fr')
the problem is solved, because I get the translations in the json object.
My question is how I can get the right data to be generated, is there a parameter to put in production.ini? Unfortunately, the documentation in CKAN is really poor so I have no leads on this. Does anybody have a clue?
Thanks!
I suspect that you might be running an unreleased branch of CKAN (eg master), so the Javascript translations have not been built.
This is done with the following command:
paster front-end-build -c config_file.ini
Just run this command and the translations should come up fine.
On the main repository this is only done just before releases to avoid complicating the git history.
Check for instance this site running the latest master branch, but on which the front end is built every night:
http://master.ckan.org/fr/dataset/world-countries

Windows Phone webclient caching "issue"?

I am trying to call the same link, but with different values, the issue is that the url is correct containing the new values but when I download it (Webclient.DownloadStringTaskAsync), it gives me the previous calls result.
I have tried adding headers no-cache, and attaching a random value to the call, and ifmodifiedSince header. however it is still not working.
any help will be much appreciated cause I have tried everything.
uri: + "&junk=" + Guid.NewGuid());
client.Headers["Cache-Control"] = "no-cache";
client.Headers[HttpRequestHeader.IfModifiedSince] = DateTime.UtcNow.ToString();
var accessdes = await client.DownloadStringTaskAsync(uri3);
so here my uri3 contains the latest values, but when I hover over accessdes, it contains the result as if I am making a old uri3 call with previous set data.
I saw one friend that was attaching a random GUID to the Url in order to prevent the OS to cache its content. For example:
if the Url were: http://www.ms.com/getdatetime and the OS is caching it.
Our solution was adding a guid for creating "sort of" like a new url, as an example our previous Url would look like: http://www.ms.com/getdatetime?cachebuster=21EC2020-3AEA-4069-A2DD-08002B30309D
(see more about cache buster : http://www.adopsinsider.com/ad-ops-basics/what-is-a-cache-buster-and-how-does-it-work/ )

Resources