Fix example urls 2861 (#2863)
* fix: fix broken link by adding API guide for creating a bucket. - add example code. - add aliases for pages moved from Tools. * fix: move create a bucket into the existing page for now. Copy example to API quick start. * Update content/influxdb/v2.0/organizations/buckets/create-bucket.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud/organizations/buckets/create-bucket.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud/organizations/buckets/create-bucket.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud/organizations/buckets/create-bucket.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/cloud/api-guide/api_intro.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Update content/influxdb/v2.0/api-guide/api_intro.md Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * fix: remove alias (#2861) * fix: replace correct URLs, hostnames, protocols (#2861) - Replaced recently added "parsed" URL objects with map() to get the hostname replacements separately. - Iterate over hostname replacements and only replace if the match isn't preceded by `/` or `.`. Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com>pull/2881/head
parent
d78aa0b7b0
commit
f0bc51f1cb
|
@ -160,16 +160,12 @@ function updateUrls(prevUrls, newUrls) {
|
|||
* then replace <prev> URL with <new> URL.
|
||||
**/
|
||||
var cloudReplacements = [
|
||||
{ replace: prevUrlsParsed.cloud.host, with: newUrlsParsed.cloud.host },
|
||||
{ replace: prevUrlsParsed.oss.host, with: newUrlsParsed.cloud.host },
|
||||
{ replace: prevUrls.cloud, with: newUrls.cloud },
|
||||
{ replace: prevUrls.oss, with: newUrls.cloud },
|
||||
{ replace: prevUrlsParsed.cloud, with: newUrlsParsed.cloud },
|
||||
{ replace: prevUrlsParsed.oss, with: newUrlsParsed.cloud },
|
||||
]
|
||||
var ossReplacements = [
|
||||
{ replace: prevUrlsParsed.cloud.host, with: newUrlsParsed.cloud.host },
|
||||
{ replace: prevUrlsParsed.oss.host, with: newUrlsParsed.oss.host },
|
||||
{ replace: prevUrls.cloud, with: newUrls.cloud},
|
||||
{ replace: prevUrls.oss, with: newUrls.oss }
|
||||
{ replace: prevUrlsParsed.cloud, with: newUrlsParsed.cloud },
|
||||
{ replace: prevUrlsParsed.oss, with: newUrlsParsed.oss },
|
||||
]
|
||||
|
||||
if (context() === "cloud") { var replacements = cloudReplacements }
|
||||
|
@ -180,10 +176,31 @@ function updateUrls(prevUrls, newUrls) {
|
|||
replacements.forEach(function (o) {
|
||||
if (o.replace != o.with) {
|
||||
$(elementSelector).each(function() {
|
||||
$(this).html($(this).html().replace(RegExp(o.replace, "g"), o.with));
|
||||
});
|
||||
$(this).html(
|
||||
$(this).html().replace(RegExp(o.replace, "g"), function(match){
|
||||
return (o.replace.protocol && o.with) || match;
|
||||
})
|
||||
);
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
replacements
|
||||
.map(function(o) {
|
||||
return {replace: o.replace.host, with: o.with.host}
|
||||
})
|
||||
.forEach(function (o) {
|
||||
if (o.replace != o.with) {
|
||||
$(elementSelector).each(function() {
|
||||
// Lookbehind matches if o.replace is not preceded by [/.].
|
||||
var hostnameOnly = new RegExp("(?<![/.])" + o.replace, "g")
|
||||
$(this).html(
|
||||
$(this).html().replace(hostnameOnly, function(match) {
|
||||
return o.with.host || o.with;
|
||||
})
|
||||
);
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Append the URL selector button to each codeblock with an InfluxDB Cloud or OSS URL
|
||||
|
|
Loading…
Reference in New Issue