Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Fixed path extraction for Windows and OSX #13

Merged
merged 5 commits into from
May 25, 2016
Merged

Fixed path extraction for Windows and OSX #13

merged 5 commits into from
May 25, 2016

Conversation

bwklein
Copy link
Contributor

@bwklein bwklein commented May 25, 2016

Corrects regex for file:\ pattern from #12 and adds in a pattern for matching quoted path string.

@ldez
Copy link
Member

ldez commented May 25, 2016

your PR breaks the package 😄

@bwklein
Copy link
Contributor Author

bwklein commented May 25, 2016

Need to update test spec for new code.

@ldez
Copy link
Member

ldez commented May 25, 2016

wait I report your fix

@ldez
Copy link
Member

ldez commented May 25, 2016

I going to switch on windows to test.

@bwklein
Copy link
Contributor Author

bwklein commented May 25, 2016

@ldez Can you check if I did it right in the updated spec?

@bwklein
Copy link
Contributor Author

bwklein commented May 25, 2016

It looks like the tests are working as expected now.

@ldez
Copy link
Member

ldez commented May 25, 2016

That doesn't work on Win7... You are using Win10?

@ldez
Copy link
Member

ldez commented May 25, 2016

why you have removed ^ and $ ?

@bwklein
Copy link
Contributor Author

bwklein commented May 25, 2016

I am testing on Windows 10 and OS X now. It works for both systems for me. What string is Windows 7 using for the path?

^ and $ could probably be added back in. It wasn't working for me when I left those in at first. I think because for my file:\ URL there is not a double-quote at the end of the string and there was no need to indicate anything at the end of it. I have added both symbols back into the double-quote stripping pattern.

@ldez
Copy link
Member

ldez commented May 25, 2016

the $ is use when you try to copy multiple file:

file:\\c:\img01.png
file:\\c:\img02.png

@ldez
Copy link
Member

ldez commented May 25, 2016

currently, we not support this behavior

clipboardText = windowsFilePattern.exec(clipboardText)[1]

if clipboardText.match windowsPathPattern
clipboardText = windowsPathPattern.exec(clipboardText)[1]
Copy link
Member

@ldez ldez May 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you rewrite this part like that:

# windows specific
windowsFilePattern = /^file:[\/]{2,3}(.*)$/
windowsPathPattern = /^\"(.*)\"$/
if clipboardText.match windowsFilePattern or clipboardText.match windowsPathPattern
  clipboardText = windowsPathPattern.exec(clipboardText)?[1] or windowsFilePattern.exec(clipboardText)?[1]

@ldez
Copy link
Member

ldez commented May 25, 2016

On Win7 the feature doesn't work because the string is always empty.

@@ -85,7 +85,17 @@ module.exports =

# Image URL support
else if atom.config.get 'asciidoc-image-helper.enableUrlSupport'
clipboardText = clipboard.readText().split(/file:[\/]{2,3}/).join('').replace /^\"|\"$/g, ''
clipboardText = clipboard.readText()
console.log clipboardText
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove console.log ?

@ldez ldez changed the title Pr/12 - Fixed pattern matching and path extraction for Windows. Fixed path extraction for Windows and OSX May 25, 2016
@ldez ldez changed the title Fixed path extraction for Windows and OSX Fixed path extraction for Windows and OSX May 25, 2016
@ldez ldez merged commit 8b6fda4 into master May 25, 2016
@ldez ldez deleted the pr/12 branch May 25, 2016 21:58
@ldez ldez added this to the 0.9.x milestone May 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants