Skip to content

Commit

Permalink
Merge pull request #4 from funzin/fix-regexp
Browse files Browse the repository at this point in the history
Fix bug not converted when the image title contains space
  • Loading branch information
funzin authored Jun 27, 2019
2 parents e45e907 + 3f43aba commit 28555f6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ImgConverter for Github",
"short_name": "ImgConverter",
"version": "0.1",
"version": "0.1.1",
"description": "ImgConverter converts from image of markdown notation to to img tag",
"manifest_version": 2,
"permissions": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imgconverter",
"version": "0.1.0",
"version": "0.1.1",
"description": "ImgConverter converts from image of markdown notation to to img tag",
"main": "karma.conf.js",
"dependencies": {
Expand Down
Binary file added resource/image/thumbnai_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions spec/js/convert-to-img-tag-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ describe("convertToImgTag", function(){
})
})

describe('when image title contains space', function () {
beforeEach(function () {
text = "hogehoge![hello world](https://user-images.githubusercontent.com/test0.png)\n \
hogehoge![hello world](https://user-images.githubusercontent.com/test1.png)"
result = convertToImgTag(text, "")
})
it('should return replaced text', function () {
text = "hogehoge<img src=https://user-images.githubusercontent.com/test0.png >\n \
hogehoge<img src=https://user-images.githubusercontent.com/test1.png >"
expect(result).toEqual(text)
})
})

describe('when text does not contain markdown image', function () {
beforeEach(function () {
text = "hogehoge\nhogehoge"
Expand Down
2 changes: 1 addition & 1 deletion src/js/convert-to-img-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function convertToImgTag(text, params) {

function createMarkdownImages(text, params) {
let markdownImageArray = []
const results = text.match(/\!\[\S*\]\(https:\/\/user-images.githubusercontent.com\S+(jpg|jpeg|png)\)/gmi)
const results = text.match(/\!\[.*\]\(https:\/\/user-images.githubusercontent.com\S+(jpg|jpeg|png)\)/gmi)
if (results == null) { return null}

for (const mdImage of results) {
Expand Down
Binary file added thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 28555f6

Please sign in to comment.