[英]Way to have browsers ignore a specific string of characters in middle of a URL?
I have a very narrow, specific case where an application takes a URL and appends the name of a specific server to the end of it from a variable passed to it, but it does it as host:servername001
.我有一个非常狭窄的特定情况,其中应用程序采用 URL 并将特定服务器的名称从传递给它的变量附加到它的末尾,但它以
host:servername001
的形式执行。 The problem is that the URL doesn't work if host:
is there.问题是如果
host:
存在,URL 不起作用。 Is there a string I can add to the URL prior to the variable that will tell it to ignore the next 5 characters (eg, the host:
) and then use the resulting URL?是否有一个字符串可以在变量之前添加到 URL 中,告诉它忽略接下来的 5 个字符(例如,
host:
:),然后使用生成的 URL?
The URL it would pass is like:它会通过的 URL 就像:
https://website1/path/server.do?sysparm_query=name=$host.name
Which results in an actual URL output of:这导致实际的 URL output 为:
https://website1/path/server.do?sysparm_query=name=host:servername001
I am looking for a way that I can have it ignore the 5 characters (host:) before the servername.我正在寻找一种可以让它忽略服务器名之前的 5 个字符(主机:)的方法。 I can control the URL string, but not the $host.name variable.
我可以控制 URL 字符串,但不能控制 $host.name 变量。
Thoughts or suggestions?想法或建议?
EDIT for clarification:编辑澄清:
I'm passing a URL and a variable to an output.我将 URL 和一个变量传递给 output。 This is all in a 3rd party app that I don't have a lot of control over.
这一切都在我无法控制的第 3 方应用程序中。 I can edit the URL.
我可以编辑 URL。 Right now, it's:
现在,它是:
https://website1/path/server.do?sysparm_query=name=
I need to append the servername from the variable at the end of that URL.我需要 append URL 末尾的变量中的服务器名。 The only one I can use for that is
我唯一可以使用的是
$host.name
Which adds "host:" right before the server name in the resulting URL.在生成的 URL 中的服务器名称之前添加“主机:”。 I need to know if there is something I can add to the URL string above, that would tell a browser to ignore "the next 5 characters" so the result is just that the URL looks like this:
我需要知道是否可以将某些内容添加到上面的 URL 字符串中,这会告诉浏览器忽略“接下来的 5 个字符”,因此结果就是 URL 看起来像这样:
https://website1/path/server.do?sysparm_query=name=servername001
Instead of like this:而不是这样:
https://website1/path/server.do?sysparm_query=name=host:servername001
Hope that makes sense...希望这是有道理的...
Here is a code snipped to append the host name without the host:
prefix:这是一段代码,截取到 append 的主机名,没有
host:
前缀:
var url = "https://website1/path/server.do?sysparm_query=name="; var $host = { name: 'host:servername001' }; var newUrl = url + $host.name.replace(/^[^:]*:/, ''); console.log('- url: ' + url); console.log('- newUrl: ' + newUrl);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.