The document identifier is not the URL of the document, but it is the UID generated when the document was created, for example, the id value after var id = createDocWithTable("doc with table") .
You need to track this identifier separately. If you have a document object, you can get it using the getId() method. The identifier is also encoded in the URL, so https://docs.google.com/document/d/3ckYOu8kuIfBzbu-Dtu9XwGHUnUJG32PK7wHe5xMv3VG/ has the document identifier 3ckYOu8kuIfBzbu-Dtu9XwGHUnUJG32PK7wHe5xMv3VG
source share