URL current incomplete wixLocate.url

hi to all;

First of all to do everything to thank Roi and Tal help me with the syntax of the code, the problem is that I can not capture the full URL in an input field, code data and screen printing

URL ORIGINAL
https://www.npcingenieria.cl/product-page/tehuelche-56-mts (for example)

THE CODE CAPTURES THIS
https://www.npcingenieria.cl/product-page/

I need you to capture the entire URL

My code

import wixLocation from ‘wix-location’;
$w.onReady(function () {
let url = wixLocation.url;
$w(‘#userInputID’).value = url; //the name of my input field ID userInputID
});

Hey Alfredo,

I keep coming back to this post but can’t seem to find an answer. Even morning coffee didn’t help. In fact, even my lunch-time beer didn’t help. It’s. That. Serious.

I tried doing this on a test site and I always get the correct URL. Both on a regular page and a lightbox, and on a dynamic page and a lightbox. Everytime - the correct URL.

What else is happening on your site? Doing anything special?

Sorry, I don’t have an answer yet - but I also didn’t want you to think that you were being ignored. :exploding_head:

Yisrael

1 Like

Hi Alfredo and Yisrael,
I’ve checked this issue more thoroughly and it seems like a bug.
We are checking it to find a solution.
It may take some time.

Roi

1 Like

I have the same issue.

I have got same issue but it seems work, I use the input to save the url the problem is now that is doesnt save url to the dataset whch is connected. Waiting help from you guys!

Can you elaborate you use the input to save the url?

import wixLocation from ‘wix-location’;
$w.onReady(function () {
let url = wixLocation.url;
$w(’ #userInputID ').value = url; //the name of my input field ID userInputID
});

The code is exactly same and I use submit form with text inputs when a new entry created that I want it to save the current url automatically to understand which product they interested.

So this gives you the full url?

Nope it does not work. Does not give me the full url from what I can see…

yes, it does but also I would suggest you to change the input tpye instead of text to URL and you may try this code below;

click dataset onready fuction try this code
export function dataset1_ready() {
let url = wixLocation.url;
$w(’ #userInputID ').value = url;
}

If you can post your full code it will be great :slight_smile:

Don’t think I can get it working even when I changed the field type to URL…

In any case, seems like a really long workaround. From what I gather, you are trying to store the URL in a database and it will format the full url there?

Hi,
Can you please share a link to your site so we can inspect ?
Roi

Hi, any update on this? Got the same issue now with domain.com/single-page/my-blog-post blog type urls and winLocation.url returns up to /single-post, and not the full url…

Can report that nearly 4 years later this still doesn’t work.

Seems the wixLocation . onChange is broken and/or incomplete, it does not return the full URL.