I am using FlowRouter with MeteorJS, and trying to create a URL with the following pattern:
topicRoute.route('/:topicName/:moduleName/portal', {...});
in this case, topicName and moduleName are route params, but I would like to have a ".../portal" url for different topicName and moduleName occurrences in the app.
This doesn't seem to work...is it not possible to put a "static part" after params?
Thank you!
Related
is there any way to switch language in nextjs without passing language parameter in url like baseurl/ar or baseurl/en ? if I want to change language from dropdown, url should not change.
query parameters are defined by the routes of your api, in this way, when you change the url, a new call is made in the api passing the parameters that were informed in the route.
you can pass objects to the api route, something like:
const response = awai api.get('yourUrl', {language: en})
this way the information will not appear in the url, but this needs to be changed in the backend so that it knows where to get the parameters from.
you can choose to do the translation in json files, and just switch between them too.
Hope this helps.
#NSL
I have read the documentation on: https://github.com/intuit/karate#path
I have also read many answers on related subject on these forums, most notably: How to dynamically create URL having path in between URL using Karate framework
However, I still cannot get my head around this concept. Perhaps I am even more a newbie than a typical newbie. My problem is this:
The complete api: /sample/api/v1/sampleweb/{sampleweb}/webversion/{version}
Feature:
Background:
* def baseUrl = '/sample/api/v1/'
#postRandomData
Scenario: POST API for creating data
Given url host
And path baseUrl
How in the world can I add the rest of the Url to "baseUrl" (basically the complete path listed above)? Should I throw "sampleweb/{sampleweb}/webversion/{version}" into a variable and then just do "baseUrl + variable"?
Please advise.
#hungryhippos what i do to have this kind of flexibility is to use something like:
var endpoint = '/sampleweb/{sampleweb}/webversion/{version}'
.replace('{sampleweb}', param1)
.replace({version}', param2)
Just use string concatenation. Just like normal JavaScript. Here try to spot the difference between "hard coded" strings and variables.
* def want = 'something'
* url baseUrl + '/anything'
* path 'you', want
i have a webscript where i try to get two parameters filename and content passed on the url when i call this webscript but when i call the webscript whith this url http://localhost:8080/alfresco/service/fr/starxpert/workflows-repository/create-save-workflow-files?filename=testFileName="testFileName"&&content="testContent" i get this error:
The Web Script /alfresco/service/fr/starxpert/workflows-repository/create-save-workflow-files has responded with a status of 404 - Not Found.
404 Description: Requested resource is not available.
Message: 06280086 Script url /fr/starxpert/workflows-repository/create-save-workflow-files does not map to a Web Script.
There is my webscript files:
createAndSaveWorkflowFile.get.desc.xml:
<webscript>
<shortname>Creation and save new workflow file</shortname>
<description>create an workflow JSON file and save it into StarXpert Workflow repository</description>
<url>/fr/starxpert/workflows-repository/create-save-workflow-files/{filename}/{content}</url>
<format default="json">extension</format>
<authentication>user</authentication>
<family>StarXpert</family>
</webscript>
createAndSaveWorkflowFile.get.js:
var fileName=args.filename;
var properties=args.content;
logger.log(fileName);
model.filename=fileName;
model.properties=properties;
createAndSaveWorkflowFile.get.json.ftl:
{
"arguments":[
"fileName":"${fileName}",
"properties":"${properties}"
]
}
Can you tell me what i make wrong, or take me an example to how call the webscript using two arguments on the url, and then get these argument on the webscript.
You have declared that your URL uses path arguments:
/fr/starxpert/workflows-repository/create-save-workflow-files/{filename}/{content}
But when you are invoking your script you are using query string arguments:
/alfresco/service/fr/starxpert/workflows-repository/create-save-workflow-files?filename=testFileName="testFileName"&&content="testContent"
Your controller assumes query string arguments, so I will assume that's what you intend.
Further, your URL looks off.
To use query string arguments your URL should be:
/alfresco/service/fr/starxpert/workflows-repository/create-save-workflow-files?filename=testFileName&content=testContent
If you want your descriptor to match that, you need to change it to:
<url>/fr/starxpert/workflows-repository/create-save-workflow-files?filename={filename}&content={content}</url>
Notice that the ampersand is escaped so that the XML remains valid.
When I tried to parse this URL:
http://localhost:3000/torrent?previous=%2Ftorrent%3Fprevious%3D%252Fuser%26route%3D&route=torrent-item
I was expecting route = 'torrent-item' (String), but FlowRouter router value is ["", "torrent-item"] (Array)
online - https://ts-vcompile.herokuapp.com/user#!/torrent?previous=%2Ftorrent%3Fprevious%3D%252Fuser%26route%3D&route=torrent-item
repo - https://github.com/HedCET/TorrentSearch
There is one key route in queryparameter which has no value. So default value assumed is an empty string. It will always return you an array of keys with same name(in this case 'route').
So you will not get route = 'torrent-item'
previous=%2Ftorrent%3Fprevious%3D%252Fuser%26route%3D&route=torrent-item
Your URL decodes as
http://localhost:3000/torrent?previous=/torrent?previous=%2Fuser&route=&route=torrent-item
cf: http://meyerweb.com/eric/tools/dencoder/
so you have &route=&route=torrent-item which will return ["", "torrent-item"] since route is there twice.
You just need to figure how to encode this URL properly to read it right.
If it's a URL you are reading from somewhere, then you need to parse the multiple arguments of the array to find what you want.
I have a ASP.NET MVC 5 website, and I'm implementing an email confirmation process based on the template from Microsoft.
While I'm composing the email body text, first I construct the URL a user will use to "click to verify your address".
To generate the security token I call:
UserManager.GenerateEmailConfirmationTokenAsync(user.Id)
This produces a code such as:
pporPNj6KzdZ3BYG8vQsKJu3dPJMwGgh+ZEGhCNnf9X6F0AS0f6qCowOQwQNfpYkl14bgEsmyPTKya5H6N4n2na2n5PgO+wpoihXxQTA7G8pK/lUYskX3jy2iA/ZM8m4Vm0prTyUuhMgfDlV+wkbR336FBRIAbKJDwOWvHHbJBDQ21gW93hyzca0li66aI1H
Obviously, this wouldn't be valid in a URL, but even URL encoding won't solve IIS's hate of such a URL.
HTTP Error 404.11 - Not Found
The request filtering module is configured to deny a request that contains a double escape sequence.
In my UserManager implementation, I'm using the tutorial boilerplate code for a TokenProvider.
var dataProtectionProvider = options.DataProtectionProvider;
if (dataProtectionProvider != null)
{
manager.UserTokenProvider = new DataProtectorTokenProvider<SiteUser>(dataProtectionProvider.Create("ASP.NET Identity"));
}
How can I make these generated tokens a bit more URL friendly? What did potentially change that would prevent the ASP.NET's tutorial code not work?
It turns out that this token will get mangled by the built in class "UrlHelper" in a MVC controller, or Url in a WebAPI controller IF the target route lists these variables as part of the path, rather than the GET vars of the URL.
Eg: this call, creates a relative URL for the site route called "ConfirmEmail" and fills in the blanks
Url.Route("ConfirmEmail", new { userId = user.Id, code = code });
Before my route was:
[Route("register-email/{code}/{userId}", Name = "ConfirmEmail")]
Changing this to:
[Route("register-email", Name = "ConfirmEmail")]
Generates valid URLS that IIS can chew through. When these are not specified, they get appended after a ? mark as normal GET vars. No idea why IIS is picky like that, but there's the solution.