Hi,
We have developed a preview of what a google search result would look like that updates as the user types (titles, descriptions, URL)
but I'm having trouble with the urlReplacing in v8
Is there a reasonable regex or similar I could use to predict what the friendly URL will be after it's published?
It doesn't have to be 100% accurate since it's only a preview but I'd like it to be as close as reasonable (without an ajax call to slow things down)
My function I started with is:
var urlify = function(input) {
return input.replace(/[ &]+/gi, '-').toLowerCase();
};
But & and space aren't the only characters I need to deal with
For example for a page named: Ice Cream & Soufflé Stored at 4°C
this function predicts the URL will be: http://localhost:24918/ice-cream-soufflé-stored-at-4°c/
I could add ° to my regex but I'm sure there are more characters.
In v7 there used to be a list of characters in umbracoSettings.config but it's not there anymore.
UrlReplacing in javascript
Hi,
We have developed a preview of what a google search result would look like that updates as the user types (titles, descriptions, URL) but I'm having trouble with the urlReplacing in v8
Is there a reasonable regex or similar I could use to predict what the friendly URL will be after it's published?
It doesn't have to be 100% accurate since it's only a preview but I'd like it to be as close as reasonable (without an ajax call to slow things down)
My function I started with is:
But & and space aren't the only characters I need to deal with For example for a page named:
Ice Cream & Soufflé Stored at 4°C
this function predicts the URL will be:http://localhost:24918/ice-cream-soufflé-stored-at-4°c/
I could add ° to my regex but I'm sure there are more characters. In v7 there used to be a list of characters in umbracoSettings.config but it's not there anymore.
Cheers.
Murray.
Hi Murry,
Do you mean this list here?
If so, here is a copy of it, but you can add it back into the
umbracoSettings.config
file in v8 as it's still valid as part of the configuration.As for a JS function to replicate it, I'm not sure I'm affraid.
Nik
is working on a reply...