Using bed to teleport across nether
Step 1. Place a bed in the exact same position in both the overworld and the nether.
Step 2. Place a nether portal within reach distance of your overworld bed.
Step 3. Wait for night.
Step 4. Enter portal.
Step 5. Just before the portal moves (5 seconds) your player into the nether, right click your bed to sleep in it.
Step 6. You should now be in the nether, wait a few seconds and you will teleport to your bed in the nether.
Using these steps it is possible to travel across distances in the nether to a bed. It may take a lot of trial and error since you have to enter the bed in the same 50ms window as the teleport takes place.
The issue here is that the isInsidePortal flag is only set during a tick and not cleared when teleporting into a bed which is no longer in a portal. This means there is a one tick window in which the flag is set but the player is not in the portal.
Suggested fix is to simply not allow portalling of sleeping players as this is easier than rejigging the inside portal checks.